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

Commit91964c3

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 parentd51d4ff commit91964c3

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
@@ -1259,7 +1259,7 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
12591259
TimestampTzcommit_time)
12601260
{
12611261
ReorderBufferTXN*txn;
1262-
ReorderBufferIterTXNState*iterstate=NULL;
1262+
ReorderBufferIterTXNState*volatileiterstate=NULL;
12631263
ReorderBufferChange*change;
12641264

12651265
volatileCommandIdcommand_id=FirstCommandId;
@@ -1304,7 +1304,6 @@ ReorderBufferCommit(ReorderBuffer *rb, TransactionId xid,
13041304

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

1475+
/* clean up the iterator */
14761476
ReorderBufferIterTXNFinish(rb,iterstate);
1477+
iterstate=NULL;
14771478

14781479
/* call commit callback */
14791480
rb->commit(rb,txn,commit_lsn);
@@ -1640,7 +1641,7 @@ ReorderBufferForget(ReorderBuffer *rb, TransactionId xid, XLogRecPtr lsn)
16401641
*/
16411642
if (txn->base_snapshot!=NULL&&txn->ninvalidations>0)
16421643
{
1643-
booluse_subtxn=IsTransactionOrTransactionBlock();
1644+
booluse_subtxn=IsTransactionOrTransactionBlock();
16441645

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp