| From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
|---|---|
| To: | Manu <manuelreyesbravo(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Cc: | Marko Grujic <marko(dot)grujic(at)enterprisedb(dot)com>, Marko Grujic <markoog(at)gmail(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz> |
| Subject: | Re: Temp schema drop leaves an inconsistent state behind |
| Date: | 2026-09-24 07:48:25 |
| Message-ID: | 9c380e18-29ac-4195-8239-1d33ee13b540@uni-muenster.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 22/09/2026 05:54, Manu wrote:
> The attached temp_schema_drop_cases.sql has all of the above as a plain
> psql script, one case per session, with what each should return. Case 8
> deletes a pg_namespace row, so it is meant for a scratch database. On
> master cases 1, 5 and 8 fail (8 by crashing, as the last statement), with
> 0001 and 0002 cases 2, 3, 6 and 7, and with the diff none.
On top of that, a just dropped schema can still be used to create
temporary objects, which creates a pg_class orphan:
psql (20devel)
Type "help" for help.
postgres=# create temporary table t();
CREATE TABLE
postgres=# \d t
Table "pg_temp_54.t"
Column | Type | Collation | Nullable | Default
--------+------+-----------+----------+---------
postgres=# select pg_my_temp_schema();
pg_my_temp_schema
-------------------
17398
(1 row)
postgres=# drop schema pg_temp_54 cascade;
NOTICE: drop cascades to table t
DROP SCHEMA
postgres=# set search_path = pg_temp, public;
SET
postgres=# create sequence s;
CREATE SEQUENCE
postgres=# select relname, relpersistence, relnamespace from pg_class
where relname = 's';
relname | relpersistence | relnamespace
---------+----------------+--------------
s | t | 17398
(1 row)
The dropped schema (oid 17398) is still being used, so a concurrent
pg_dump will also fail:
$ pg_dump postgres
pg_dump: error: schema with OID 17398 does not exist
IIUC the problem is that activeCreationNamespace is used when the
relpersistence is not RELPERSISTENCE_TEMP. So with pg_temp first in
search_path, activeCreationNamespace is the dropped schema.
Thanks!
Best, Jim
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Xuneng Zhou | 2026-09-24 07:49:35 | Logical slot creation/synchronization on a standby may deadlock with recovery conflict resolution |
| Previous Message | Chao Li | 2026-09-24 07:39:22 | Re: [PATCH] Add ALTER SYSTEM RELOAD |