@@ -226,32 +226,27 @@ dtm_xact_callback(XactEvent event, void *arg)
226
226
break ;
227
227
228
228
case XACT_EVENT_ABORT_PREPARED :
229
- // DtmLocalAbortPrepared(&dtm_tx);
230
229
finishing_prepared = true;
231
230
DtmAdjustOldestXid ();
232
231
break ;
233
232
234
233
case XACT_EVENT_COMMIT_PREPARED :
235
- // DtmLocalCommitPrepared(&dtm_tx);
236
234
finishing_prepared = true;
237
235
DtmAdjustOldestXid ();
238
236
break ;
239
237
240
238
case XACT_EVENT_COMMIT :
241
239
DtmLocalFinish (true);
242
- DtmLocalEnd (& dtm_tx );
243
240
finishing_prepared = false;
244
241
break ;
245
242
246
243
case XACT_EVENT_ABORT :
247
244
DtmLocalFinish (false);
248
- DtmLocalEnd (& dtm_tx );
249
245
finishing_prepared = false;
250
246
break ;
251
247
252
248
case XACT_EVENT_PRE_PREPARE :
253
249
DtmLocalSavePreparedState (& dtm_tx );
254
- DtmLocalEnd (& dtm_tx );
255
250
break ;
256
251
257
252
default :
@@ -452,11 +447,9 @@ DtmInitialize()
452
447
void
453
448
DtmLocalBegin (DtmCurrentTrans * x )
454
449
{
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 );
460
453
}
461
454
462
455
/*
@@ -477,7 +470,6 @@ DtmLocalExtend(GlobalTransactionId gtid)
477
470
id -> xid = GetCurrentTransactionId ();
478
471
id -> nSubxids = 0 ;
479
472
id -> subxids = 0 ;
480
- x -> xid = id -> xid ;
481
473
}
482
474
strncpy (x -> gtid ,gtid ,MAX_GTID_SIZE );
483
475
SpinLockRelease (& local -> lock );
@@ -495,6 +487,8 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
495
487
{
496
488
cid_t local_cid ;
497
489
490
+ // Check that snapshot isn't set?
491
+
498
492
SpinLockAcquire (& local -> lock );
499
493
{
500
494
if (gtid != NULL )
@@ -504,17 +498,18 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
504
498
id -> xid = GetCurrentTransactionId ();
505
499
id -> nSubxids = 0 ;
506
500
id -> subxids = 0 ;
507
- x -> xid = id -> xid ;
508
501
}
509
502
local_cid = dtm_sync (global_cid );
510
503
x -> snapshot = global_cid ;
511
504
}
512
505
strncpy (x -> gtid ,gtid ,MAX_GTID_SIZE );
513
506
SpinLockRelease (& local -> lock );
507
+
514
508
if (global_cid < local_cid - DtmVacuumDelay * USEC )
515
509
{
516
510
elog (ERROR ,"Too old snapshot: requested %ld, current %ld" ,global_cid ,local_cid );
517
511
}
512
+
518
513
DtmInitGlobalXmin (TransactionXmin );
519
514
return global_cid ;
520
515
}
@@ -663,23 +658,10 @@ DtmLocalFinish(bool is_commit)
663
658
ts -> nSubxids = 0 ;
664
659
}
665
660
}
666
- x -> cid = ts -> cid ;
667
- DTM_TRACE ((stderr ,"Local transaction %u is committed at %lu\n" ,x -> xid ,x -> cid ));
668
661
}
669
662
SpinLockRelease (& local -> lock );
670
663
671
664
// 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 ;
683
665
}
684
666
685
667
/*