@@ -118,7 +118,6 @@ static shmem_startup_hook_type prev_shmem_startup_hook;
118118static HTAB * xid_in_doubt ;
119119static HTAB * local_trans ;
120120static DtmState * dtm ;
121- static Snapshot CurrentTransactionSnapshot ;
122121
123122static TransactionId DtmNextXid ;
124123static SnapshotData DtmSnapshot = { HeapTupleSatisfiesMVCC };
@@ -609,8 +608,9 @@ static Snapshot DtmGetSnapshot(Snapshot snapshot)
609608{
610609 if (TransactionIdIsValid (DtmNextXid ) && snapshot != & CatalogSnapshotData )
611610 {
612- if (!DtmHasGlobalSnapshot && (snapshot != DtmLastSnapshot || DtmCurcid != snapshot -> curcid ))
611+ if (!DtmHasGlobalSnapshot && (snapshot != DtmLastSnapshot || DtmCurcid != snapshot -> curcid )) {
613612 DtmGlobalGetSnapshot (DtmNextXid , & DtmSnapshot , & dtm -> minXid );
613+ }
614614 DtmCurcid = snapshot -> curcid ;
615615 DtmLastSnapshot = snapshot ;
616616 DtmMergeWithGlobalSnapshot (snapshot );
@@ -628,7 +628,6 @@ static Snapshot DtmGetSnapshot(Snapshot snapshot)
628628 snapshot = PgGetSnapshotData (snapshot );
629629 }
630630 DtmUpdateRecentXmin (snapshot );
631- CurrentTransactionSnapshot = snapshot ;
632631 return snapshot ;
633632}
634633
@@ -651,7 +650,6 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
651650 {
652651 if (TransactionIdIsValid (DtmNextXid ))
653652 {
654- CurrentTransactionSnapshot = NULL ;
655653 if (status == TRANSACTION_STATUS_ABORTED || !MMIsDistributedTrans )
656654 {
657655 PgTransactionIdSetTreeStatus (xid , nsubxids , subxids , status , lsn );
@@ -662,7 +660,7 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
662660 else
663661 {
664662 XTM_INFO ("Begin commit transaction %d\n" , xid );
665- /* Mark transaction as on -doubt in xid_in_doubt hash table */
663+ /* Mark transaction as in -doubt in xid_in_doubt hash table */
666664 LWLockAcquire (dtm -> hashLock , LW_EXCLUSIVE );
667665 hash_search (xid_in_doubt , & DtmNextXid , HASH_ENTER , NULL );
668666 LWLockRelease (dtm -> hashLock );
@@ -673,20 +671,22 @@ static void DtmSetTransactionStatus(TransactionId xid, int nsubxids, Transaction
673671 MarkAsAborted ();
674672 END_CRIT_SECTION ();
675673 elog (ERROR , "Transaction commit rejected by XTM" );
674+ } else {
675+ XTM_INFO ("Commit transaction %d\n" , xid );
676676 }
677- XTM_INFO ("Commit transaction %d\n" , xid );
678677 }
679678 }
680679 else
681680 {
682681 XTM_INFO ("Set transaction %u status in local CLOG" , xid );
683682 }
684683 }
685- else
684+ else if ( status != TRANSACTION_STATUS_ABORTED )
686685 {
687686 XidStatus gs ;
688687 gs = DtmGlobalGetTransStatus (xid , false);
689688 if (gs != TRANSACTION_STATUS_UNKNOWN ) {
689+ Assert (gs != TRANSACTION_STATUS_IN_PROGRESS );
690690 status = gs ;
691691 }
692692 }
@@ -753,23 +753,21 @@ static void DtmInitialize()
753753static void
754754DtmXactCallback (XactEvent event , void * arg )
755755{
756- XTM_INFO ("%d: DtmXactCallbackevent=%d nextxid=%d\n" , getpid (), event , DtmNextXid );
756+ // XTM_INFO("%d: DtmXactCallbackevent=%d nextxid=%d\n", getpid(), event, DtmNextXid);
757757 switch (event )
758758 {
759759 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());
762762 if (IsNormalProcessingMode () && dtm -> initialized && MMDoReplication && !IsBackgroundWorker && !IsAutoVacuumWorkerProcess ()) {
763763 MMBeginTransaction ();
764764 }
765765 break ;
766766 case XACT_EVENT_PRE_COMMIT :
767767 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 );
773771 }
774772 break ;
775773 case XACT_EVENT_COMMIT :
0 commit comments