pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: Mahendra Singh Thalor <mahi6run@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@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: Thu, 16 Jan 2020 13:06:18 +0900
Message-ID: <20200116040618.GF3117@paquier.xyz> (raw)
In-Reply-To: <20200110110748.GD250447@paquier.xyz>
References: <20200107002216.GA2386@paquier.xyz>
	<CA+TgmoYCd6gaCy2-YzO5DyR=YFxRAbKaC5ucL9DL4jSnTgs14A@mail.gmail.com>
	<14868.1578420368@sss.pgh.pa.us>
	<20200108004409.GA3413@paquier.xyz>
	<5602.1578444917@sss.pgh.pa.us>
	<20200108015601.GB3413@paquier.xyz>
	<20200109040612.GG2251@paquier.xyz>
	<CAKYtNArmm0f4zYHebpQ9kf7LOJeiuexKSnnmhiOiLQc3_F39ug@mail.gmail.com>
	<20200110080125.GA250447@paquier.xyz>
	<20200110110748.GD250447@paquier.xyz>

On Fri, Jan 10, 2020 at 08:07:48PM +0900, Michael Paquier wrote:
> Thinking more about it, this has a race condition if a temporary
> schema is removed after collecting the OIDs in the drop phase.  So the
> updated attached is actually much more conservative and does not need
> an update of the log message, without giving up on the improvements
> done in v11~.  In 9.4~10, the code of the second phase relies on
> GetTempNamespaceBackendId() which causes an orphaned relation to not
> be dropped in the event of a missing namespace.  I'll just leave that
> alone for a couple of days now..

And back on that one, I still like better the solution as of the
attached which skips any relations with their namespace gone missing
as 246a6c87's intention was only to allow orphaned temp relations to
be dropped by autovacuum when a backend slot is connected, but not
using yet its own temp namespace.

If we want the drop of temp relations to work properly, more thoughts
are needed regarding the storage part, and I am not actually sure that
it is autovacuum's job to handle that better.

Any thoughts?
--
Michael

Attachments:

drop-temp-schema-adjust-v6.patch (text/x-diff, 1.7K) download diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index f0e40e36af..9eb8132a37 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -2071,9 +2071,11 @@ do_autovacuum(void) { /* * We just ignore it if the owning backend is still active and - * using the temporary schema. + * using the temporary schema. If the namespace does not exist + * ignore the entry. */ - if (!isTempNamespaceInUse(classForm->relnamespace)) + if (!isTempNamespaceInUse(classForm->relnamespace) && + get_namespace_name(classForm->relnamespace) != NULL) { /* * The table seems to be orphaned -- although it might be that @@ -2202,6 +2204,7 @@ do_autovacuum(void) Oid relid = lfirst_oid(cell); Form_pg_class classForm; ObjectAddress object; + char *nspname; /* * Check for user-requested abort. @@ -2243,7 +2246,15 @@ do_autovacuum(void) continue; } - if (isTempNamespaceInUse(classForm->relnamespace)) + nspname = get_namespace_name(classForm->relnamespace); + + /* + * Nothing to do for a relation with a missing namespace. This + * check is the same as above when building the list of orphan + * relations. + */ + if (isTempNamespaceInUse(classForm->relnamespace) || + nspname == NULL) { UnlockRelationOid(relid, AccessExclusiveLock); continue; @@ -2253,8 +2264,7 @@ do_autovacuum(void) ereport(LOG, (errmsg("autovacuum: dropping orphan temp table \"%s.%s.%s\"", get_database_name(MyDatabaseId), - get_namespace_name(classForm->relnamespace), - NameStr(classForm->relname)))); + nspname, NameStr(classForm->relname)))); object.classId = RelationRelationId; object.objectId = relid;
signature.asc (application/pgp-signature, 832B) download

view thread (37+ messages)  latest in thread

Message-ID: <20200116040618.GF3117@paquier.xyz>
Permalink:  ../20200116040618.GF3117@paquier.xyz/
Also on:    postgresql.org/message-id/20200116040618.GF3117@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, mahi6run@gmail.com, tgl@sss.pgh.pa.us, robertmhaas@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: <20200116040618.GF3117@paquier.xyz>
  References: <20200107002216.GA2386@paquier.xyz> <CA+TgmoYCd6gaCy2-YzO5DyR=YFxRAbKaC5ucL9DL4jSnTgs14A@mail.gmail.com> <14868.1578420368@sss.pgh.pa.us> <20200108004409.GA3413@paquier.xyz> <5602.1578444917@sss.pgh.pa.us> <20200108015601.GB3413@paquier.xyz> <20200109040612.GG2251@paquier.xyz> <CAKYtNArmm0f4zYHebpQ9kf7LOJeiuexKSnnmhiOiLQc3_F39ug@mail.gmail.com> <20200110080125.GA250447@paquier.xyz> <20200110110748.GD250447@paquier.xyz> <20200116040618.GF3117@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