@@ -118,7 +118,6 @@ static shmem_startup_hook_type prev_shmem_startup_hook;
118
118
static HTAB * xid_in_doubt ;
119
119
static HTAB * local_trans ;
120
120
static DtmState * dtm ;
121
- static Snapshot CurrentTransactionSnapshot ;
122
121
123
122
static TransactionId DtmNextXid ;
124
123
static SnapshotData DtmSnapshot = {HeapTupleSatisfiesMVCC };
@@ -609,8 +608,9 @@ static Snapshot DtmGetSnapshot(Snapshot snapshot)
609
608
{
610
609
if (TransactionIdIsValid (DtmNextXid )&& snapshot != & CatalogSnapshotData )
611
610
{
612
- if (!DtmHasGlobalSnapshot && (snapshot != DtmLastSnapshot || DtmCurcid != snapshot -> curcid ))
611
+ if (!DtmHasGlobalSnapshot && (snapshot != DtmLastSnapshot || DtmCurcid != snapshot -> curcid )) {
613
612
DtmGlobalGetSnapshot (DtmNextXid ,& DtmSnapshot ,& dtm -> minXid );
613
+ }
614
614
DtmCurcid = snapshot -> curcid ;
615
615
DtmLastSnapshot = snapshot ;
616
616
DtmMergeWithGlobalSnapshot (snapshot );
@@ -628,7 +628,6 @@ static Snapshot DtmGetSnapshot(Snapshot snapshot)
628
628
snapshot = PgGetSnapshotData (snapshot );
629
629
}
630
630
DtmUpdateRecentXmin (snapshot );
631
- CurrentTransactionSnapshot = snapshot ;
632
631
return snapshot ;
633
632
}
634
633
@@ -651,7 +650,6 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
651
650
{
652
651
if (TransactionIdIsValid (DtmNextXid ))
653
652
{
654
- CurrentTransactionSnapshot = NULL ;
655
653
if (status == TRANSACTION_STATUS_ABORTED || !MMIsDistributedTrans )
656
654
{
657
655
PgTransactionIdSetTreeStatus (xid ,nsubxids ,subxids ,status ,lsn );
@@ -662,7 +660,7 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
662
660
else
663
661
{
664
662
XTM_INFO ("Begin commit transaction %d\n" ,xid );
665
- /* Mark transaction ason -doubt in xid_in_doubt hash table */
663
+ /* Mark transaction asin -doubt in xid_in_doubt hash table */
666
664
LWLockAcquire (dtm -> hashLock ,LW_EXCLUSIVE );
667
665
hash_search (xid_in_doubt ,& DtmNextXid ,HASH_ENTER ,NULL );
668
666
LWLockRelease (dtm -> hashLock );
@@ -673,20 +671,22 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
673
671
MarkAsAborted ();
674
672
END_CRIT_SECTION ();
675
673
elog (ERROR ,"Transaction commit rejected by XTM" );
674
+ }else {
675
+ XTM_INFO ("Commit transaction %d\n" ,xid );
676
676
}
677
- XTM_INFO ("Commit transaction %d\n" ,xid );
678
677
}
679
678
}
680
679
else
681
680
{
682
681
XTM_INFO ("Set transaction %u status in local CLOG" ,xid );
683
682
}
684
683
}
685
- else
684
+ else if ( status != TRANSACTION_STATUS_ABORTED )
686
685
{
687
686
XidStatus gs ;
688
687
gs = DtmGlobalGetTransStatus (xid , false);
689
688
if (gs != TRANSACTION_STATUS_UNKNOWN ) {
689
+ Assert (gs != TRANSACTION_STATUS_IN_PROGRESS );
690
690
status = gs ;
691
691
}
692
692
}
@@ -753,23 +753,21 @@ static void DtmInitialize()
753
753
static void
754
754
DtmXactCallback (XactEvent event ,void * arg )
755
755
{
756
- XTM_INFO ("%d: DtmXactCallbackevent=%d nextxid=%d\n" ,getpid (),event ,DtmNextXid );
756
+ // XTM_INFO("%d: DtmXactCallbackevent=%d nextxid=%d\n", getpid(), event, DtmNextXid);
757
757
switch (event )
758
758
{
759
759
case XACT_EVENT_START :
760
- XTM_INFO ("%d: normal=%d, initialized=%d, replication=%d, bgw=%d, vacuum=%d\n" ,
761
- getpid (),IsNormalProcessingMode (),dtm -> initialized ,MMDoReplication ,IsBackgroundWorker ,IsAutoVacuumWorkerProcess ());
760
+ // XTM_INFO("%d: normal=%d, initialized=%d, replication=%d, bgw=%d, vacuum=%d\n",
761
+ // getpid(), IsNormalProcessingMode(), dtm->initialized, MMDoReplication, IsBackgroundWorker, IsAutoVacuumWorkerProcess());
762
762
if (IsNormalProcessingMode ()&& dtm -> initialized && MMDoReplication && !IsBackgroundWorker && !IsAutoVacuumWorkerProcess ()) {
763
763
MMBeginTransaction ();
764
764
}
765
765
break ;
766
766
case XACT_EVENT_PRE_COMMIT :
767
767
case XACT_EVENT_PARALLEL_PRE_COMMIT :
768
- if (!MMIsDistributedTrans && TransactionIdIsValid (GetCurrentTransactionIdIfAny ())) {
769
- XTM_INFO ("%d: Will ignore transaction %u\n" ,getpid (),GetCurrentTransactionIdIfAny ());
770
- MMMarkTransAsLocal (GetCurrentTransactionIdIfAny ());
771
- }else {
772
- XTM_INFO ("%d: Transaction %u will be replicated\n" ,getpid (),GetCurrentTransactionIdIfAny ());
768
+ if (!MMIsDistributedTrans && TransactionIdIsValid (DtmNextXid )) {
769
+ XTM_INFO ("%d: Will ignore transaction %u\n" ,getpid (),DtmNextXid );
770
+ MMMarkTransAsLocal (DtmNextXid );
773
771
}
774
772
break ;
775
773
case XACT_EVENT_COMMIT :