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

Commitea6eda6

Browse files
committed
Clean up after erroneous SELECT FOR UPDATE/SHARE on a sequence.
My previous commit disallowed this operation, but did nothing aboutcleaning up the damage if one had already been done. With the operationdisallowed, it's okay to just forcibly clear xmax in a sequence's tuple,since any value seen there could not represent a live transaction's lock.So, any sequence-specific operation will repair the problem automatically,whether or not the user has already seen "could not access status oftransaction" failures.
1 parent5295fa8 commitea6eda6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎src/backend/commands/sequence.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,22 @@ read_info(SeqTable elm, Relation rel, Buffer *buf)
10761076
Assert(ItemIdIsNormal(lp));
10771077
tuple.t_data= (HeapTupleHeader)PageGetItem(page,lp);
10781078

1079+
/*
1080+
* Previous releases of Postgres neglected to prevent SELECT FOR UPDATE
1081+
* on a sequence, which would leave a non-frozen XID in the sequence
1082+
* tuple's xmax, which eventually leads to clog access failures or worse.
1083+
* If we see this has happened, clean up after it. We treat this like a
1084+
* hint bit update, ie, don't bother to WAL-log it, since we can certainly
1085+
* do this again if the update gets lost.
1086+
*/
1087+
if (HeapTupleHeaderGetXmax(tuple.t_data)!=InvalidTransactionId)
1088+
{
1089+
HeapTupleHeaderSetXmax(tuple.t_data,InvalidTransactionId);
1090+
tuple.t_data->t_infomask &= ~HEAP_XMAX_COMMITTED;
1091+
tuple.t_data->t_infomask |=HEAP_XMAX_INVALID;
1092+
SetBufferCommitInfoNeedsSave(*buf);
1093+
}
1094+
10791095
seq= (Form_pg_sequence)GETSTRUCT(&tuple);
10801096

10811097
/* this is a handy place to update our copy of the increment */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp