Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit112d055

Browse files
committed
Lock owned sequences during ALTER TABLE SET { LOGGED | UNLOGGED }.
These commands already make the persistence of owned sequences followowned table persistence changes. They didn't lock those sequences.They lost the effect of nextval() calls that other sessions make afterthe 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 tov15, where commit344d62f introducedunlogged sequences.Reviewed (in an earlier version) by Robert Haas.Discussion:https://postgr.es/m/20240611024525.9f.nmisch@google.com
1 parentf8135d8 commit112d055

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

‎src/backend/commands/sequence.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,13 @@ SequenceChangePersistence(Oid relid, char newrelpersistence)
557557
Bufferbuf;
558558
HeapTupleDataseqdatatuple;
559559

560+
/*
561+
* ALTER SEQUENCE acquires this lock earlier. If we're processing an
562+
* owned sequence for ALTER TABLE, lock now. Without the lock, we'd
563+
* discard increments from nextval() calls (in other sessions) between
564+
* this function's buffer unlock and this transaction's commit.
565+
*/
566+
LockRelationOid(relid,AccessExclusiveLock);
560567
init_sequence(relid,&elm,&seqrel);
561568

562569
/* check the comment above nextval_internal()'s equivalent call. */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp