@@ -479,8 +479,6 @@ create_rel_estate(Relation rel)
479
479
static bool
480
480
process_remote_begin (StringInfo s , GlobalTransactionId * gtid )
481
481
{
482
- TransactionId xid ;
483
-
484
482
gtid -> node = pq_getmsgint (s , 4 );
485
483
gtid -> xid = pq_getmsgint64 (s );
486
484
@@ -496,8 +494,8 @@ process_remote_begin(StringInfo s, GlobalTransactionId *gtid)
496
494
StartTransactionCommand ();
497
495
498
496
/* ddd */
499
- xid = GetCurrentTransactionId ();
500
- MtmDeadlockDetectorAddXact (xid , gtid );
497
+ gtid -> my_xid = GetCurrentTransactionId ();
498
+ MtmDeadlockDetectorAddXact (gtid -> my_xid , gtid );
501
499
502
500
// AcceptInvalidationMessages();
503
501
// if (!receiver_mtm_cfg_valid)
@@ -955,18 +953,17 @@ process_remote_commit(StringInfo in, GlobalTransactionId *current_gtid, MtmRecei
955
953
res = PrepareTransactionBlock (gid );
956
954
mtm_log (MtmTxFinish , "TXFINISH: %s prepared" , gid );
957
955
956
+ CommitTransactionCommand ();
957
+
958
958
/*
959
- * Clean this before CommitTransactionCommand(). Otherwise we'll
960
- * have a time window where exception handler will try to call
961
- * MtmDeadlockDetectorRemoveXact() with InvalidTransactionId,
962
- * because there is already no active transaction.
959
+ * Clean this after CommitTransactionCommand(), as it may throw an
960
+ * error that we should propagate to the originating node.
963
961
*/
964
962
current_gtid -> node = 0 ;
965
963
current_gtid -> xid = InvalidTransactionId ;
964
+ current_gtid -> my_xid = InvalidTransactionId ;
966
965
MtmDeadlockDetectorRemoveXact (xid );
967
966
968
- CommitTransactionCommand ();
969
-
970
967
if (receiver_ctx -> parallel_allowed )
971
968
{
972
969
TransactionId origin_xid = MtmGidParseXid (gid );
@@ -1614,7 +1611,7 @@ MtmExecutor(void* work, size_t size, MtmReceiverContext *receiver_ctx)
1614
1611
/* handle only prepare errors here */
1615
1612
if (TransactionIdIsValid (current_gtid .xid ))
1616
1613
{
1617
- MtmDeadlockDetectorRemoveXact (GetCurrentTransactionIdIfAny () );
1614
+ MtmDeadlockDetectorRemoveXact (current_gtid . my_xid );
1618
1615
if (receiver_ctx -> parallel_allowed )
1619
1616
mtm_send_reply (current_gtid .xid , current_gtid .node , MSG_ABORTED );
1620
1617
}
0 commit comments