Skip to content

Commit e14e2f9

Browse files
committed
do not assign xid too early -- fix breakage of regression tests
1 parent 5f096fa commit e14e2f9

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/backend/access/transam/global_snapshot.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ dtm_xact_callback(XactEvent event, void *arg)
242242
DtmLocalCommitPrepared(&dtm_tx);
243243
break;
244244

245-
case XACT_EVENT_PREPARE:
245+
case XACT_EVENT_PRE_PREPARE:
246246
DtmLocalSavePreparedState(&dtm_tx);
247247
DtmLocalEnd(&dtm_tx);
248248
break;
@@ -488,8 +488,6 @@ DtmLocalBegin(DtmCurrentTrans * x)
488488
{
489489
SpinLockAcquire(&local->lock);
490490
// x->xid = GetCurrentTransactionIdIfAny();
491-
x->xid = GetCurrentTransactionId();
492-
// Assert(TransactionIdIsValid(x->xid));
493491
x->cid = INVALID_CID;
494492
x->is_global = false;
495493
x->is_prepared = false;
@@ -653,8 +651,8 @@ DtmLocalEndPrepare(GlobalTransactionId gtid, cid_t cid)
653651
void
654652
DtmLocalCommitPrepared(DtmCurrentTrans * x)
655653
{
656-
// if (!x->is_global)
657-
// return;
654+
if (!x->gtid[0])
655+
return;
658656

659657
Assert(x->gtid != NULL);
660658

@@ -727,8 +725,8 @@ DtmLocalCommit(DtmCurrentTrans * x)
727725
void
728726
DtmLocalAbortPrepared(DtmCurrentTrans * x)
729727
{
730-
// if (!x->is_global)
731-
// return;
728+
if (!x->gtid[0])
729+
return;
732730

733731
Assert(x->gtid != NULL);
734732

@@ -752,8 +750,8 @@ DtmLocalAbortPrepared(DtmCurrentTrans * x)
752750
void
753751
DtmLocalAbort(DtmCurrentTrans * x)
754752
{
755-
// if (!x->is_global)
756-
// return;
753+
if (!TransactionIdIsValid(x->xid))
754+
return;
757755

758756
SpinLockAcquire(&local->lock);
759757
{
@@ -861,6 +859,7 @@ DtmLocalSavePreparedState(DtmCurrentTrans * x)
861859
TransactionId *subxids;
862860
int nSubxids = xactGetCommittedChildren(&subxids);
863861

862+
id->xid = GetCurrentTransactionId();
864863
if (nSubxids != 0)
865864
{
866865
id->subxids = (TransactionId *) malloc(nSubxids * sizeof(TransactionId));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy