@@ -85,7 +85,6 @@ typedef struct
85
85
86
86
// static shmem_startup_hook_type prev_shmem_startup_hook;
87
87
static HTAB * xid2status ;
88
- static HTAB * gtid2xid ;
89
88
static DtmNodeState * local ;
90
89
static uint64 totalSleepInterrupts ;
91
90
static int DtmVacuumDelay = 15 ; /* sec */
@@ -432,13 +431,6 @@ DtmInitialize()
432
431
& info ,
433
432
HASH_ELEM | HASH_BLOBS );
434
433
435
- info .keysize = MAX_GTID_SIZE ;
436
- info .entrysize = sizeof (DtmTransId );
437
- gtid2xid = ShmemInitHash ("gtid2xid" ,
438
- DTM_HASH_INIT_SIZE , DTM_HASH_INIT_SIZE ,
439
- & info ,
440
- HASH_ELEM );
441
-
442
434
TM = & DtmTM ;
443
435
444
436
LWLockAcquire (AddinShmemInitLock , LW_EXCLUSIVE );
@@ -478,16 +470,7 @@ DtmLocalExtend(GlobalTransactionId gtid)
478
470
479
471
if (gtid != NULL )
480
472
{
481
- SpinLockAcquire (& local -> lock );
482
- {
483
- DtmTransId * id = (DtmTransId * ) hash_search (gtid2xid , gtid , HASH_ENTER , NULL );
484
-
485
- id -> xid = GetCurrentTransactionId ();
486
- id -> nSubxids = 0 ;
487
- id -> subxids = 0 ;
488
- }
489
473
strncpy (x -> gtid , gtid , MAX_GTID_SIZE );
490
- SpinLockRelease (& local -> lock );
491
474
}
492
475
DtmInitGlobalXmin (TransactionXmin );
493
476
return x -> snapshot ;
@@ -506,14 +489,6 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
506
489
507
490
SpinLockAcquire (& local -> lock );
508
491
{
509
- if (gtid != NULL )
510
- {
511
- DtmTransId * id = (DtmTransId * ) hash_search (gtid2xid , gtid , HASH_ENTER , NULL );
512
-
513
- id -> xid = GetCurrentTransactionId ();
514
- id -> nSubxids = 0 ;
515
- id -> subxids = 0 ;
516
- }
517
492
local_cid = dtm_sync (global_cid );
518
493
x -> snapshot = global_cid ;
519
494
}
@@ -536,18 +511,20 @@ DtmLocalAccess(DtmCurrentTrans * x, GlobalTransactionId gtid, cid_t global_cid)
536
511
void
537
512
DtmLocalBeginPrepare (GlobalTransactionId gtid )
538
513
{
539
- // TransactionId xid = TwoPhaseGetTransactionId(gtid);
514
+ TransactionId xid = TwoPhaseGetTransactionId (gtid );
515
+
516
+ if (!TransactionIdIsValid (xid ))
517
+ {
518
+ // XXX: check that it is global tx with the same xid, XactTopTransactionId?
519
+ xid = GetCurrentTransactionId ();
520
+ }
540
521
541
522
SpinLockAcquire (& local -> lock );
542
523
{
543
524
DtmTransStatus * ts ;
544
- DtmTransId * id ;
545
525
bool found ;
546
526
547
- id = (DtmTransId * ) hash_search (gtid2xid , gtid , HASH_FIND , NULL );
548
- Assert (id != NULL );
549
- Assert (TransactionIdIsValid (id -> xid ));
550
- ts = (DtmTransStatus * ) hash_search (xid2status , & id -> xid , HASH_ENTER , & found );
527
+ ts = (DtmTransStatus * ) hash_search (xid2status , & xid , HASH_ENTER , & found );
551
528
ts -> status = TRANSACTION_STATUS_UNKNOWN ;
552
529
ts -> cid = dtm_get_cid ();
553
530
if (!found )
@@ -582,15 +559,23 @@ DtmLocalPrepare(GlobalTransactionId gtid, cid_t global_cid)
582
559
void
583
560
DtmLocalEndPrepare (GlobalTransactionId gtid , cid_t cid )
584
561
{
562
+ TransactionId xid = TwoPhaseGetTransactionId (gtid );
563
+
564
+ if (!TransactionIdIsValid (xid ))
565
+ {
566
+ // XXX: check that it is global tx with the same xid, XactTopTransactionId?
567
+ xid = GetCurrentTransactionId ();
568
+ }
569
+
570
+ dtm_tx .xid = xid ;
571
+
585
572
SpinLockAcquire (& local -> lock );
586
573
{
587
574
DtmTransStatus * ts ;
588
575
DtmTransId * id ;
589
576
int i ;
590
577
591
- id = (DtmTransId * ) hash_search (gtid2xid , gtid , HASH_FIND , NULL );
592
-
593
- ts = (DtmTransStatus * ) hash_search (xid2status , & id -> xid , HASH_FIND , NULL );
578
+ ts = (DtmTransStatus * ) hash_search (xid2status , & xid , HASH_FIND , NULL );
594
579
Assert (ts != NULL );
595
580
ts -> cid = cid ;
596
581
DtmAdjustSubtransactions (ts );
@@ -613,19 +598,7 @@ DtmLocalFinish(bool is_commit)
613
598
614
599
if (x -> gtid [0 ] && finishing_prepared )
615
600
{
616
- // Assert(!TransactionIdIsValid(xid));
617
-
618
- SpinLockAcquire (& local -> lock );
619
- {
620
- DtmTransId * id = (DtmTransId * ) hash_search (gtid2xid , x -> gtid , HASH_REMOVE , NULL );
621
-
622
- Assert (id != NULL );
623
- Assert (TransactionIdIsValid (id -> xid ));
624
-
625
- xid = id -> xid ;
626
- free (id -> subxids );
627
- }
628
- SpinLockRelease (& local -> lock );
601
+ xid = x -> xid ;
629
602
}
630
603
else if (!TransactionIdIsValid (xid ))
631
604
{
@@ -716,20 +689,6 @@ DtmLocalSavePreparedState(DtmCurrentTrans * x)
716
689
int nSubxids = xactGetCommittedChildren (& subxids );
717
690
718
691
SpinLockAcquire (& local -> lock );
719
- {
720
- DtmTransId * id = (DtmTransId * ) hash_search (gtid2xid , x -> gtid , HASH_FIND , NULL );
721
-
722
- if (id != NULL )
723
- {
724
- id -> xid = GetCurrentTransactionId ();
725
-
726
- }
727
- }
728
- // SpinLockRelease(&local->lock);
729
-
730
-
731
-
732
- // SpinLockAcquire(&local->lock);
733
692
{
734
693
DtmTransStatus * ts ;
735
694
0 commit comments