pgsql: Lock owned sequences during ALTER TABLE SET { LOGGED | UNLOGGED

From: Noah Misch <noah(at)leadboat(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Lock owned sequences during ALTER TABLE SET { LOGGED | UNLOGGED
Date: 2024-06-28 02:26:54
Message-ID: [email protected]
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Lock owned sequences during ALTER TABLE SET { LOGGED | UNLOGGED }.

These commands already make the persistence of owned sequences follow
owned table persistence changes. They didn't lock those sequences.
They lost the effect of nextval() calls that other sessions make after
the ALTER TABLE command, before the ALTER TABLE transaction commits.
Fix by acquiring the same lock that ALTER SEQUENCE SET { LOGGED |
UNLOGGED } acquires. This might cause more deadlocks. Back-patch to
v15, where commit 344d62fb9a978a72cf8347f0369b9ee643fd0b31 introduced
unlogged sequences.

Reviewed (in an earlier version) by Robert Haas.

Discussion: https://postgr.es/m/[email protected]

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/24561b498f117fc7ec58baba27b0d89c9efab376

Modified Files
--------------
src/backend/commands/sequence.c | 7 +++++++
1 file changed, 7 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Noah Misch 2024-06-28 02:26:55 pgsql: AccessExclusiveLock new relations just after assigning the OID.
Previous Message Amit Langote 2024-06-28 00:46:29 pgsql: SQL/JSON: Document behavior when input document is not jsonb