@@ -226,32 +226,27 @@ dtm_xact_callback(XactEvent event, void *arg)
226226 break ;
227227
228228 case XACT_EVENT_ABORT_PREPARED :
229- // DtmLocalAbortPrepared(&dtm_tx);
230229 finishing_prepared = true;
231230 DtmAdjustOldestXid ();
232231 break ;
233232
234233 case XACT_EVENT_COMMIT_PREPARED :
235- // DtmLocalCommitPrepared(&dtm_tx);
236234 finishing_prepared = true;
237235 DtmAdjustOldestXid ();
238236 break ;
239237
240238 case XACT_EVENT_COMMIT :
241239 DtmLocalFinish (true);
242- DtmLocalEnd (& dtm_tx );
243240 finishing_prepared = false;
244241 break ;
245242
246243 case XACT_EVENT_ABORT :
247244 DtmLocalFinish (false);
248- DtmLocalEnd (& dtm_tx );
249245 finishing_prepared = false;
250246 break ;
251247
252248 case XACT_EVENT_PRE_PREPARE :
253249 DtmLocalSavePreparedState (& dtm_tx );
254- DtmLocalEnd (& dtm_tx );
255250 break ;
256251
257252 default :
@@ -452,11 +447,9 @@ DtmInitialize()
452447void
453448DtmLocalBegin (DtmCurrentTrans * x )
454449{
455- SpinLockAcquire (& local -> lock );
456- x -> cid = INVALID_CID ;
457- x -> snapshot = dtm_get_cid ();
458- SpinLockRelease (& local -> lock );
459- DTM_TRACE ((stderr , "DtmLocalBegin: transaction %u uses local snapshot %lu\n" , x -> xid , x -> snapshot ));
450+ SpinLockAcquire (& local -> lock ); // XXX: move to snapshot aquire?
451+ x -> snapshot = dtm_get_cid ();
452+ SpinLockRelease (& local -> lock );
460453}
461454
462455/*
@@ -477,7 +470,6 @@ DtmLocalExtend(GlobalTransactionId gtid)
477470 id -> xid = GetCurrentTransactionId ();
478471 id -> nSubxids = 0 ;
479472 id -> subxids = 0 ;
480- x -> xid = id -> xid ;
481473 }
482474 strncpy (x -> gtid , gtid , MAX_GTID_SIZE );
483475 SpinLockRelease (& local -> lock );
@@ -495,6 +487,8 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
495487{
496488 cid_t local_cid ;
497489
490+ // Check that snapshot isn't set?
491+
498492 SpinLockAcquire (& local -> lock );
499493 {
500494 if (gtid != NULL )
@@ -504,17 +498,18 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
504498 id -> xid = GetCurrentTransactionId ();
505499 id -> nSubxids = 0 ;
506500 id -> subxids = 0 ;
507- x -> xid = id -> xid ;
508501 }
509502 local_cid = dtm_sync (global_cid );
510503 x -> snapshot = global_cid ;
511504 }
512505 strncpy (x -> gtid , gtid , MAX_GTID_SIZE );
513506 SpinLockRelease (& local -> lock );
507+
514508 if (global_cid < local_cid - DtmVacuumDelay * USEC )
515509 {
516510 elog (ERROR , "Too old snapshot: requested %ld, current %ld" , global_cid , local_cid );
517511 }
512+
518513 DtmInitGlobalXmin (TransactionXmin );
519514 return global_cid ;
520515}
@@ -663,23 +658,10 @@ DtmLocalFinish(bool is_commit)
663658 ts -> nSubxids = 0 ;
664659 }
665660 }
666- x -> cid = ts -> cid ;
667- DTM_TRACE ((stderr , "Local transaction %u is committed at %lu\n" , x -> xid , x -> cid ));
668661 }
669662 SpinLockRelease (& local -> lock );
670663
671664 // DtmAdjustOldestXid();
672- // elog(LOG, "DtmLocalCommit %d", x->xid);
673- }
674-
675- /*
676- * Cleanup dtm_tx structure
677- */
678- void
679- DtmLocalEnd (DtmCurrentTrans * x )
680- {
681- x -> xid = InvalidTransactionId ;
682- x -> cid = INVALID_CID ;
683665}
684666
685667/*
0 commit comments