pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Mahendra Singh <mahi6run@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Assert failure due to "drop schema pg_temp_3 cascade" for temporary tables and \d+ is not showing any info after drooping temp table schema
Date: Wed, 8 Jan 2020 09:44:09 +0900
Message-ID: <20200108004409.GA3413@paquier.xyz> (raw)
In-Reply-To: <14868.1578420368@sss.pgh.pa.us>
References: <28862.1577382716@sss.pgh.pa.us>
	<CAKYtNApQ4ctL5AnP+2rSoV9vB+cmXp5OiwponY5QL_w4C5SH_w@mail.gmail.com>
	<20191227090604.GA540891@paquier.xyz>
	<CA+TgmobL4npEX5=E5h=5Jm_9mZun3MT39Kq2suJFVeamc9skSQ@mail.gmail.com>
	<20200106014202.GA3598@paquier.xyz>
	<CA+TgmobPJ+CQGr1nKnt4rNikgBqHvXtJ+x8UW0U_kR6ksf2D-A@mail.gmail.com>
	<31319.1578332027@sss.pgh.pa.us>
	<20200107002216.GA2386@paquier.xyz>
	<CA+TgmoYCd6gaCy2-YzO5DyR=YFxRAbKaC5ucL9DL4jSnTgs14A@mail.gmail.com>
	<14868.1578420368@sss.pgh.pa.us>

On Tue, Jan 07, 2020 at 01:06:08PM -0500, Tom Lane wrote:
> I still agree with Robert that a052f6c is a bad idea.  It's not the case
> that that's blocking "any connected user" from causing an issue.  The
> temp schemas are always owned by the bootstrap superuser, so only a
> superuser could delete them.  All that that patch is doing is preventing
> superusers from doing something that they could reasonably wish to do,
> and that is perfectly safe when there's not concurrent usage of the
> schema.  We are not normally that nanny-ish, and the case for being so
> here seems pretty thin.

Okay, I am running out of arguments then, so attached is a patch to
address things.  I would also prefer if we keep the relation name in
the log even if the namespace is missing.
--
Michael

Attachments:

drop-temp-schema-adjust-v2.patch (text/x-diff, 2.2K) download diff --git a/src/backend/commands/dropcmds.c b/src/backend/commands/dropcmds.c index e7891a4418..b3131ab208 100644 --- a/src/backend/commands/dropcmds.c +++ b/src/backend/commands/dropcmds.c @@ -101,21 +101,6 @@ RemoveObjects(DropStmt *stmt) errhint("Use DROP AGGREGATE to drop aggregate functions."))); } - /* - * Prevent the drop of a temporary schema, be it owned by the current - * session or another backend as this would mess up with the callback - * registered to clean up temporary objects at the end of a session. - * Note also that the creation of any follow-up temporary object would - * result in inconsistencies within the session whose temporary schema - * has been dropped. - */ - if (stmt->removeType == OBJECT_SCHEMA && - isAnyTempNamespace(address.objectId)) - ereport(ERROR, - (errcode(ERRCODE_WRONG_OBJECT_TYPE), - errmsg("cannot drop temporary schema \"%s\"", - get_namespace_name(address.objectId)))); - /* Check permissions. */ namespaceId = get_object_namespace(&address); if (!OidIsValid(namespaceId) || diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index f0e40e36af..f6afe4dbb8 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -2250,11 +2250,22 @@ do_autovacuum(void) } /* OK, let's delete it */ - ereport(LOG, - (errmsg("autovacuum: dropping orphan temp table \"%s.%s.%s\"", - get_database_name(MyDatabaseId), - get_namespace_name(classForm->relnamespace), - NameStr(classForm->relname)))); + if (log_min_messages <= LOG) + { + char *nspname = get_namespace_name(classForm->relnamespace); + + if (nspname != NULL) + ereport(LOG, + (errmsg("autovacuum: dropping orphan temp table \"%s.%s.%s\"", + get_database_name(MyDatabaseId), + get_namespace_name(classForm->relnamespace), + NameStr(classForm->relname)))); + else + ereport(LOG, + (errmsg("autovacuum: dropping orphan temp table \"%s.(null).%s\" with OID %u", + get_database_name(MyDatabaseId), + NameStr(classForm->relname), relid))); + } object.classId = RelationRelationId; object.objectId = relid;
signature.asc (application/pgp-signature, 832B) download

view thread (37+ messages)  latest in thread

Message-ID: <20200108004409.GA3413@paquier.xyz>
Permalink:  ../20200108004409.GA3413@paquier.xyz/
Also on:    postgresql.org/message-id/20200108004409.GA3413@paquier.xyz

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: michael@paquier.xyz, tgl@sss.pgh.pa.us, robertmhaas@gmail.com, mahi6run@gmail.com, horikyota.ntt@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Assert failure due to "drop schema pg_temp_3 cascade" for temporary tables and \d+ is not showing any info after drooping temp table schema
  In-Reply-To: <20200108004409.GA3413@paquier.xyz>
  References: <28862.1577382716@sss.pgh.pa.us> <CAKYtNApQ4ctL5AnP+2rSoV9vB+cmXp5OiwponY5QL_w4C5SH_w@mail.gmail.com> <20191227090604.GA540891@paquier.xyz> <CA+TgmobL4npEX5=E5h=5Jm_9mZun3MT39Kq2suJFVeamc9skSQ@mail.gmail.com> <20200106014202.GA3598@paquier.xyz> <CA+TgmobPJ+CQGr1nKnt4rNikgBqHvXtJ+x8UW0U_kR6ksf2D-A@mail.gmail.com> <31319.1578332027@sss.pgh.pa.us> <20200107002216.GA2386@paquier.xyz> <CA+TgmoYCd6gaCy2-YzO5DyR=YFxRAbKaC5ucL9DL4jSnTgs14A@mail.gmail.com> <14868.1578420368@sss.pgh.pa.us> <20200108004409.GA3413@paquier.xyz>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox