@@ -96,6 +96,7 @@ typedef enum
96
96
#define MTM_MAP_SIZE 1003
97
97
#define MIN_WAIT_TIMEOUT 1000
98
98
#define MAX_WAIT_TIMEOUT 100000
99
+ #define MAX_WAIT_LOOPS 100
99
100
#define STATUS_POLL_DELAY USECS_PER_SEC
100
101
101
102
void _PG_init (void );
@@ -419,8 +420,9 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
419
420
static timestamp_t maxSleepTime ;
420
421
#endif
421
422
timestamp_t delay = MIN_WAIT_TIMEOUT ;
423
+ int i ;
422
424
Assert (xid != InvalidTransactionId );
423
-
425
+
424
426
if (!MtmUseDtm ) {
425
427
return PgXidInMVCCSnapshot (xid , snapshot );
426
428
}
@@ -431,7 +433,8 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
431
433
firstReportTime = MtmGetCurrentTime ();
432
434
}
433
435
#endif
434
- while (true)
436
+
437
+ for (i = 0 ; i < MAX_WAIT_LOOPS ; i ++ )
435
438
{
436
439
MtmTransState * ts = (MtmTransState * )hash_search (MtmXid2State , & xid , HASH_FIND , NULL );
437
440
if (ts != NULL && ts -> status != TRANSACTION_STATUS_IN_PROGRESS )
@@ -484,11 +487,13 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
484
487
else
485
488
{
486
489
MTM_LOG4 ("%d: visibility check is skept for transaction %u in snapshot %lu" , MyProcPid , xid , MtmTx .snapshot );
487
- break ;
490
+ MtmUnlock ();
491
+ return PgXidInMVCCSnapshot (xid , snapshot );
488
492
}
489
493
}
490
494
MtmUnlock ();
491
- return PgXidInMVCCSnapshot (xid , snapshot );
495
+ elog (ERROR , "Failed to get status of XID %d" , xid );
496
+ return true;
492
497
}
493
498
494
499
@@ -1200,7 +1205,7 @@ static void MtmEnableNode(int nodeId)
1200
1205
1201
1206
void MtmRecoveryCompleted (void )
1202
1207
{
1203
- MTM_LOG1 ("Recovery of node %d is completed, disabled mask=%lx, reconnect mask=%ld , live nodes=%d" ,
1208
+ MTM_LOG1 ("Recovery of node %d is completed, disabled mask=%lx, reconnect mask=%lx , live nodes=%d" ,
1204
1209
MtmNodeId , Mtm -> disabledNodeMask , Mtm -> reconnectMask , Mtm -> nLiveNodes );
1205
1210
MtmLock (LW_EXCLUSIVE );
1206
1211
Mtm -> recoverySlot = 0 ;
0 commit comments