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
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Mahendra Singh Thalor <mahi6run@gmail.com>, Robert Haas <robertmhaas@gmail.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-01-11T00:03:23Z
Lists: pgsql-bugs, pgsql-hackers
On Fri, Jan 10, 2020 at 09:50:58AM -0500, Tom Lane wrote: > This doesn't seem like a very good idea to me. Is there any > evidence that it's fixing an actual problem? What if the table > you're skipping is holding back datfrozenxid? That's the point I wanted to make sure: we don't because autovacuum has never actually been able to do that and because the cluster is put in this state by a superuser after issuing DROP SCHEMA on its temporary schema, which allows many fancy things based on the inconsistent state the session is on. Please see see for example REL_10_STABLE where GetTempNamespaceBackendId() would return InvalidBackendId when the namespace does not exist, so the drop is skipped. 246a6c8 (designed to track if a backend slot is using a temp namespace or not, allowing cleanup of orphaned tables if the namespace is around, still not used yet by the session it is assigned to) has changed the logic, accidentally actually, to also allow an orphaned temp table to be dropped even if its namespace does not exist anymore. If we say that it's fine for autovacuum to allow the drop of such inconsistent pg_class entries, then we would need to either remove or relax the assertion in relcache.c:1123 (RelationBuildDesc, should only autovacuum be allowed to do so?) to begin to allow autovacuum to remove temp relations. However, this does not sound like a correct thing to do IMO. So, note that if autovacuum is allowed to do so, you basically defeat partially the purpose of the assertion added by debcec7d in relcache.c. Another thing noticeable is that If autovacuum does the pg_class entry drops, the on-disk files for the temp relations would remain until the cluster is restarted by the way. -- Michael
Commits
-
Avoid failure if autovacuum tries to access a just-dropped temp namespace.
- d7684c38a5e9 12.3 landed
- 80d76be51cfb 13.0 landed
- 7ea20a2bc6bd 11.8 landed
-
Revert "Forbid DROP SCHEMA on temporary namespaces"
- b83ba2e6e706 9.4.26 landed
- 86949c2f1207 9.5.21 landed
- 50174b70e779 9.6.17 landed
- 0c046f816902 10.12 landed
- 789bc293b341 11.7 landed
- a1c003e5ff82 12.2 landed
- 65192e02441c 13.0 landed
-
Forbid DROP SCHEMA on temporary namespaces
- 898e0c650097 9.4.26 landed
- 12cb5478a2a4 9.5.21 landed
- cb6f94a5219d 9.6.17 landed
- f1958351eae2 10.12 landed
- 786540085dbd 11.7 landed
- 1dd88201ad6e 12.2 landed
- a052f6cbb84e 13.0 landed
-
Make autovacuum more aggressive to remove orphaned temp tables
- 246a6c8f7b23 12.0 cited
-
Code review for early drop of orphaned temp relations in autovacuum.
- dafa0848da11 10.0 cited