Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 9cf4eaa

Browse files
committed
Fix failure to advance nextXID beyond subtransactions whose XIDs appear
only within COMMIT or ABORT records.
1 parent af8406b commit 9cf4eaa

File tree

1 file changed

+42
-6
lines changed
  • src/backend/access/transam

1 file changed

+42
-6
lines changed

src/backend/access/transam/xact.c

+42-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.184 2004/08/30 02:54:38 momjian Exp $
13+
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.185 2004/08/30 19:00:03 tgl Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -3462,12 +3462,30 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
34623462
if (info == XLOG_XACT_COMMIT)
34633463
{
34643464
xl_xact_commit *xlrec = (xl_xact_commit *) XLogRecGetData(record);
3465+
TransactionId *sub_xids;
3466+
TransactionId max_xid;
34653467
int i;
34663468

34673469
TransactionIdCommit(record->xl_xid);
3470+
34683471
/* Mark committed subtransactions as committed */
3469-
TransactionIdCommitTree(xlrec->nsubxacts,
3470-
(TransactionId *) &(xlrec->xnodes[xlrec->nrels]));
3472+
sub_xids = (TransactionId *) &(xlrec->xnodes[xlrec->nrels]);
3473+
TransactionIdCommitTree(xlrec->nsubxacts, sub_xids);
3474+
3475+
/* Make sure nextXid is beyond any XID mentioned in the record */
3476+
max_xid = record->xl_xid;
3477+
for (i = 0; i < xlrec->nsubxacts; i++)
3478+
{
3479+
if (TransactionIdPrecedes(max_xid, sub_xids[i]))
3480+
max_xid = sub_xids[i];
3481+
}
3482+
if (TransactionIdFollowsOrEquals(max_xid,
3483+
ShmemVariableCache->nextXid))
3484+
{
3485+
ShmemVariableCache->nextXid = max_xid;
3486+
TransactionIdAdvance(ShmemVariableCache->nextXid);
3487+
}
3488+
34713489
/* Make sure files supposed to be dropped are dropped */
34723490
for (i = 0; i < xlrec->nrels; i++)
34733491
{
@@ -3478,12 +3496,30 @@ xact_redo(XLogRecPtr lsn, XLogRecord *record)
34783496
else if (info == XLOG_XACT_ABORT)
34793497
{
34803498
xl_xact_abort *xlrec = (xl_xact_abort *) XLogRecGetData(record);
3499+
TransactionId *sub_xids;
3500+
TransactionId max_xid;
34813501
int i;
34823502

34833503
TransactionIdAbort(record->xl_xid);
3484-
/* mark subtransactions as aborted */
3485-
TransactionIdAbortTree(xlrec->nsubxacts,
3486-
(TransactionId *) &(xlrec->xnodes[xlrec->nrels]));
3504+
3505+
/* Mark subtransactions as aborted */
3506+
sub_xids = (TransactionId *) &(xlrec->xnodes[xlrec->nrels]);
3507+
TransactionIdAbortTree(xlrec->nsubxacts, sub_xids);
3508+
3509+
/* Make sure nextXid is beyond any XID mentioned in the record */
3510+
max_xid = record->xl_xid;
3511+
for (i = 0; i < xlrec->nsubxacts; i++)
3512+
{
3513+
if (TransactionIdPrecedes(max_xid, sub_xids[i]))
3514+
max_xid = sub_xids[i];
3515+
}
3516+
if (TransactionIdFollowsOrEquals(max_xid,
3517+
ShmemVariableCache->nextXid))
3518+
{
3519+
ShmemVariableCache->nextXid = max_xid;
3520+
TransactionIdAdvance(ShmemVariableCache->nextXid);
3521+
}
3522+
34873523
/* Make sure files supposed to be dropped are dropped */
34883524
for (i = 0; i < xlrec->nrels; i++)
34893525
{

0 commit comments

Comments
 (0)