@@ -95,6 +95,7 @@ DtmCurrentTrans dtm_tx; // XXXX: make static
9595
9696static bool DtmXidInMVCCSnapshot (TransactionId xid , Snapshot snapshot );
9797static void DtmAdjustOldestXid (void );
98+ static void DtmInitGlobalXmin (TransactionId xid );
9899static bool DtmDetectGlobalDeadLock (PGPROC * proc );
99100static void DtmAddSubtransactions (DtmTransStatus * ts , TransactionId * subxids , int nSubxids );
100101static char const * DtmGetName (void );
@@ -365,6 +366,17 @@ DtmAdjustOldestXid()
365366 // elog(LOG, "DtmAdjustOldestXid total=%d, deleted=%d, xid=%d, prev=%p, ts=%p", total, deleted, oldest_xid, prev, ts);
366367}
367368
369+ static void
370+ DtmInitGlobalXmin (TransactionId xid )
371+ {
372+ TransactionId current_xmin ;
373+
374+ /* Better change to CAS */
375+ current_xmin = ProcArrayGetGlobalSnapshotXmin ();
376+ if (!TransactionIdIsValid (current_xmin ))
377+ ProcArraySetGlobalSnapshotXmin (xid );
378+ }
379+
368380
369381/*
370382 * Check tuple bisibility based on CSN of current transaction.
@@ -503,6 +515,7 @@ DtmLocalExtend(GlobalTransactionId gtid)
503515 SpinLockRelease (& local -> lock );
504516 }
505517 x -> is_global = true;
518+ DtmInitGlobalXmin (x -> xid );
506519 return x -> snapshot ;
507520}
508521
@@ -524,6 +537,7 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
524537 id -> xid = GetCurrentTransactionId ();
525538 id -> nSubxids = 0 ;
526539 id -> subxids = 0 ;
540+ x -> xid = id -> xid ;
527541 }
528542 local_cid = dtm_sync (global_cid );
529543 x -> snapshot = global_cid ;
@@ -535,6 +549,7 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
535549 {
536550 elog (ERROR , "Too old snapshot: requested %ld, current %ld" , global_cid , local_cid );
537551 }
552+ DtmInitGlobalXmin (x -> xid );
538553 return global_cid ;
539554}
540555
0 commit comments