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

Commitf8a4dd2

Browse files
committed
Fix unsafe coding in ReorderBufferCommit().
"iterstate" must be marked volatile since it's changed inside the PG_TRYblock and then used in the PG_CATCH stanza. Noted by Mark Wilding ofSalesforce. (We really need to see if we can't get the C compiler to warnabout this.)Also, reset iterstate to NULL after the mainline ReorderBufferIterTXNFinishcall, to ensure the PG_CATCH block doesn't try to do that a second time.
1 parent586dd5d commitf8a4dd2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎src/backend/replication/logical/reorderbuffer.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,7 +1258,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
12581258
TimestampTzcommit_time)
12591259
{
12601260
ReorderBufferTXN*txn;
1261-
ReorderBufferIterTXNState*iterstate=NULL;
1261+
ReorderBufferIterTXNState*volatileiterstate=NULL;
12621262
ReorderBufferChange*change;
12631263

12641264
volatileCommandIdcommand_id=FirstCommandId;
@@ -1303,7 +1303,6 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
13031303

13041304
PG_TRY();
13051305
{
1306-
13071306
/*
13081307
* Decoding needs access to syscaches et al., which in turn use
13091308
* heavyweight locks and such. Thus we need to have enough state
@@ -1472,7 +1471,9 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
14721471
}
14731472
}
14741473

1474+
/* clean up the iterator */
14751475
ReorderBufferIterTXNFinish(rb,iterstate);
1476+
iterstate=NULL;
14761477

14771478
/* call commit callback */
14781479
rb->commit(rb,txn,commit_lsn);
@@ -1639,7 +1640,7 @@ ReorderBufferForget(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
16391640
*/
16401641
if (txn->base_snapshot!=NULL&&txn->ninvalidations>0)
16411642
{
1642-
booluse_subtxn=IsTransactionOrTransactionBlock();
1643+
booluse_subtxn=IsTransactionOrTransactionBlock();
16431644

16441645
if (use_subtxn)
16451646
BeginInternalSubTransaction("replay");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp