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

Commitf88cdb3

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 parentd5f788b commitf88cdb3

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
@@ -545,6 +545,13 @@ SequenceChangePersistence(Oid relid, char newrelpersistence)
545545
Bufferbuf;
546546
HeapTupleDataseqdatatuple;
547547

548+
/*
549+
* ALTER SEQUENCE acquires this lock earlier. If we're processing an
550+
* owned sequence for ALTER TABLE, lock now. Without the lock, we'd
551+
* discard increments from nextval() calls (in other sessions) between
552+
* this function's buffer unlock and this transaction's commit.
553+
*/
554+
LockRelationOid(relid,AccessExclusiveLock);
548555
init_sequence(relid,&elm,&seqrel);
549556

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp