Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1irwQW-0005UJ-73 for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Jan 2020 04:06:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1irwQT-0005iv-Ux for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Jan 2020 04:06:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1irwQT-0005io-GB for pgsql-hackers@lists.postgresql.org; Thu, 16 Jan 2020 04:06:33 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1irwQM-00088A-IC for pgsql-hackers@lists.postgresql.org; Thu, 16 Jan 2020 04:06:32 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id AA4A0753; Wed, 15 Jan 2020 23:06:23 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Wed, 15 Jan 2020 23:06:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=MdNhKfseQF4+3p/IrpSZdzVkwPn ALny7gUzS+/dTAeg=; b=IC1Lkp899N9giR+uOp6Hr3NkcuCc28DnpKm6wTp4zJZ eZQacTbHLYGd9fGHUc3m1yuJDx/d3xaHXRFLUB8ka1PCCn6JbVIeCANKbk3pURv8 B9DY5Dz7tA6bIuf0H40cqBrO98WrX1fZu/nShGQUg3I4o8DMDyy8PbuOWi8jvAhT vz4UAtFtdMSB/6hvaTE9AWea+CPgEI7U965x+Y+wL0BwSR7ZuEwDVi9veQ/yY7ek edeElHivtIiNbtOLpHXA0V5kwjvaeEOFbIlT9IwJAACLlJHRVVsAMzWPA0aJBbPY 1T9a/1Nwb/t/XdXxms5/xhFJ1ZPzL0OLc+06iRlBjfA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=MdNhKf seQF4+3p/IrpSZdzVkwPnALny7gUzS+/dTAeg=; b=CsHZhx9I0VoGlkXBRXpIC2 d5XDJSrJZj8H9tlrkP+6KpoQxGLD5zNkzG2h5sD3ehQ584qPrxnTyAzHUQlNfYEw suu7HY3D7wLneH9yky4wDT9ot/Hh8a+Z5HKZvcHVZvil8CZWixOqHYLYU2Nssxoi /8y9+8+ZP/SRklMbQNv1p0yBbC0l1FqSl2RGlbf5lBhCoX+3U/7Ywx41cZXVFnRA +3bW74HDO5kNIKdnluLoKvzx49U4S6c4UiAinHO50JxNWts3KyOI8GoNV+45XB02 D7n3wbYL2hIHPo3cyMtKHeaLQYSVEqLJqpSIRlMT15J+xB2b0mPGQ2DiaOd4EKiA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrtdeggdeifecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdejtddmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecukfhppeduuddurddutddvrddukedtrddukeehnecurfgrrhgr mhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiinecuvehluh hsthgvrhfuihiivgeptd X-ME-Proxy: Received: from paquier.xyz (ee0822lan1.rev.em-net.ne.jp [111.102.180.185]) by mail.messagingengine.com (Postfix) with ESMTPA id 47B6D30600A8; Wed, 15 Jan 2020 23:06:21 -0500 (EST) Date: Thu, 16 Jan 2020 13:06:18 +0900 From: Michael Paquier To: Mahendra Singh Thalor Cc: Tom Lane , Robert Haas , Kyotaro Horiguchi , PostgreSQL Hackers 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 Message-ID: <20200116040618.GF3117@paquier.xyz> References: <20200107002216.GA2386@paquier.xyz> <14868.1578420368@sss.pgh.pa.us> <20200108004409.GA3413@paquier.xyz> <5602.1578444917@sss.pgh.pa.us> <20200108015601.GB3413@paquier.xyz> <20200109040612.GG2251@paquier.xyz> <20200110080125.GA250447@paquier.xyz> <20200110110748.GD250447@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="fmvA4kSBHQVZhkR6" Content-Disposition: inline In-Reply-To: <20200110110748.GD250447@paquier.xyz> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --fmvA4kSBHQVZhkR6 Content-Type: multipart/mixed; boundary="0OWHXb1mYLuhj1Ox" Content-Disposition: inline --0OWHXb1mYLuhj1Ox Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --0OWHXb1mYLuhj1Ox Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="drop-temp-schema-adjust-v6.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/a= utovacuum.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) !=3D NULL) { /* * The table seems to be orphaned -- although it might be that @@ -2202,6 +2204,7 @@ do_autovacuum(void) Oid relid =3D lfirst_oid(cell); Form_pg_class classForm; ObjectAddress object; + char *nspname; =20 /* * Check for user-requested abort. @@ -2243,7 +2246,15 @@ do_autovacuum(void) continue; } =20 - if (isTempNamespaceInUse(classForm->relnamespace)) + nspname =3D 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 =3D=3D 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)))); =20 object.classId =3D RelationRelationId; object.objectId =3D relid; --0OWHXb1mYLuhj1Ox-- --fmvA4kSBHQVZhkR6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAl4f4ToACgkQnvQgOdby QH3AdQ//W0Plm7B0JzCy9ThPPxniiG3Hizf/HHfzaCvS7dWV1s58WkXLqnn/4pKb xzRPWL5EljFWlsESS4RMkM+FLpRojEuteow48+tv4LB9duRsmo7WvVOxhkESHFsU ZG737DS6kfxh221irPXpqh6Briaedd10oc9zgOv0UjCsl4i9a6SWabXnZErYU66r 7mmJjaA0ymOjui12BVKOVBcDsVYTlaodJCxcPg8XE12RhyYRg/C2Edi1bl+gWVq+ sGFLvg0C8iHWVUVvkuUjLUx533du3OG7GwnM2Tmsh802ymuhJePXFANGD/qLbbyp HOpwxG80vRWDPT6NCNxbzcJuDT4tBw2kJ8cTUqNvjYmCjXQ01A4iLSTJuGjA+omP Iu0UBxJrlp7aX1zbeH+dmu2Ig+Ci69fQTcnCRR0lCPOcf8llIIfIg7Ro7/tBGMMy IKIHEuM6TYfDaNsVKqpjm/2eLKYd4qKjft9ARsCLgfVW0ohudraUuQ8lDoBIwaO3 qFUts/H4WfBLxjN7lGPIarurFAZ+s0HxVJcqtgTgkQWvpG1eGj5yheQRQPzedjyq l7IIWMgoyc20UJpjkCjphT8hwCBqwMULMi+8uwccX5CZh1yirNijD1sp7T2SUKYL t25hMHgSpUgFIC201yH530/efhRomRMGieg8lnc48f11kaM/vik= =ALSd -----END PGP SIGNATURE----- --fmvA4kSBHQVZhkR6--