@@ -90,8 +90,8 @@ static TransactionManager DtmTM = { DtmGetTransactionStatus, DtmSetTransactionSt
90
90
91
91
92
92
#define XTM_TRACE (fmt , ...)
93
- #define XTM_INFO (fmt , ...) fprintf(stderr, fmt, ## __VA_ARGS__)
94
- // #define XTM_INFO(fmt, ...)
93
+ // #define XTM_INFO(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__)
94
+ #define XTM_INFO (fmt , ...)
95
95
96
96
static void DumpSnapshot (Snapshot s ,char * name )
97
97
{
@@ -195,20 +195,24 @@ static void DtmMergeSnapshots(Snapshot dst, Snapshot src)
195
195
196
196
static TransactionId DtmGetOldestXmin (Relation rel ,bool ignoreVacuum )
197
197
{
198
- TransactionId xmin = GetOldestLocalXmin (rel ,ignoreVacuum );
199
- #if 0
200
- if (TransactionIdIsValid (DtmSnapshot .xmin )&& TransactionIdPrecedes (DtmSnapshot .xmin ,xmin )) {
201
- xmin = DtmSnapshot .xmin ;
198
+ TransactionId localXmin = GetOldestLocalXmin (rel ,ignoreVacuum );
199
+ TransactionId globalXmin = DtmMinXid ;
200
+ if (TransactionIdIsValid (globalXmin )) {
201
+ globalXmin -= vacuum_defer_cleanup_age ;
202
+ if (!TransactionIdIsNormal (globalXmin )) {
203
+ globalXmin = FirstNormalTransactionId ;
204
+ }
205
+ if (TransactionIdPrecedes (globalXmin ,localXmin )) {
206
+ localXmin = globalXmin ;
207
+ }
202
208
}
203
- #endif
204
- return xmin ;
209
+ return localXmin ;
205
210
}
206
211
207
212
static void DtmUpdateRecentXmin (void )
208
213
{
209
214
TransactionId xmin = DtmMinXid ;//DtmSnapshot.xmin;
210
-
211
- XTM_TRACE ("XTM: DtmUpdateRecentXmin \n" );
215
+ XTM_INFO ("XTM: DtmUpdateRecentXmin global xmin=%d, snapshot xmin %d\n" ,DtmMinXid ,DtmSnapshot .xmin );
212
216
213
217
if (TransactionIdIsValid (xmin )) {
214
218
xmin -= vacuum_defer_cleanup_age ;
@@ -394,7 +398,6 @@ DtmGetNewTransactionId(bool isSubXact)
394
398
* Extend pg_subtrans and pg_commit_ts too.
395
399
*/
396
400
if (TransactionIdFollowsOrEquals (xid ,ShmemVariableCache -> nextXid )) {
397
- fprintf (stderr ,"Extend CLOG to %d\n" ,xid );
398
401
ExtendCLOG (xid );
399
402
ExtendCommitTs (xid );
400
403
ExtendSUBTRANS (xid );
@@ -477,18 +480,17 @@ DtmGetNewTransactionId(bool isSubXact)
477
480
478
481
static Snapshot DtmGetSnapshot (Snapshot snapshot )
479
482
{
480
-
481
483
if (TransactionIdIsValid (DtmNextXid )) {
482
484
if (!DtmHasGlobalSnapshot ) {
483
485
DtmGlobalGetSnapshot (DtmNextXid ,& DtmSnapshot ,& DtmMinXid );
484
486
}
485
487
DtmMergeSnapshots (snapshot ,& DtmSnapshot );
486
- if (!IsolationUsesXactSnapshot ()) {
487
- DtmHasGlobalSnapshot = false;
488
- }
488
+ if (!IsolationUsesXactSnapshot ()) {
489
+ DtmHasGlobalSnapshot = false;
490
+ }
489
491
}else {
490
- snapshot = GetLocalSnapshotData (snapshot );
491
- }
492
+ snapshot = GetLocalSnapshotData (snapshot );
493
+ }
492
494
DtmUpdateRecentXmin ();
493
495
CurrentTransactionSnapshot = snapshot ;
494
496
return snapshot ;
@@ -710,7 +712,7 @@ Datum dtm_join_transaction(PG_FUNCTION_ARGS)
710
712
Assert (TransactionIdIsValid (DtmNextXid ));
711
713
XTM_INFO ("%d: Join global transaction %d\n" ,getpid (),DtmNextXid );
712
714
713
- DtmGlobalGetSnapshot (DtmNextXid ,& DtmSnapshot );
715
+ DtmGlobalGetSnapshot (DtmNextXid ,& DtmSnapshot , & DtmMinXid );
714
716
715
717
DtmHasGlobalSnapshot = true;
716
718
DtmIsGlobalTransaction = true;