Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9c31d02

Browse files
knizhnikkelvich
authored andcommitted
Avoid infinite loop in visibility check
1 parent2afd9cc commit9c31d02

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎multimaster.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ typedef enum
9797
#defineMTM_MAP_SIZE 1003
9898
#defineMIN_WAIT_TIMEOUT 1000
9999
#defineMAX_WAIT_TIMEOUT 100000
100+
#defineMAX_WAIT_LOOPS 100
100101
#defineSTATUS_POLL_DELAY USECS_PER_SEC
101102

102103
void_PG_init(void);
@@ -424,8 +425,9 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
424425
statictimestamp_tmaxSleepTime;
425426
#endif
426427
timestamp_tdelay=MIN_WAIT_TIMEOUT;
428+
inti;
427429
Assert(xid!=InvalidTransactionId);
428-
430+
429431
if (!MtmUseDtm) {
430432
returnPgXidInMVCCSnapshot(xid,snapshot);
431433
}
@@ -436,7 +438,8 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
436438
firstReportTime=MtmGetCurrentTime();
437439
}
438440
#endif
439-
while (true)
441+
442+
for (i=0;i<MAX_WAIT_LOOPS;i++)
440443
{
441444
MtmTransState*ts= (MtmTransState*)hash_search(MtmXid2State,&xid,HASH_FIND,NULL);
442445
if (ts!=NULL&&ts->status!=TRANSACTION_STATUS_IN_PROGRESS)
@@ -489,11 +492,13 @@ bool MtmXidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
489492
else
490493
{
491494
MTM_LOG4("%d: visibility check is skept for transaction %u in snapshot %lu",MyProcPid,xid,MtmTx.snapshot);
492-
break;
495+
MtmUnlock();
496+
returnPgXidInMVCCSnapshot(xid,snapshot);
493497
}
494498
}
495499
MtmUnlock();
496-
returnPgXidInMVCCSnapshot(xid,snapshot);
500+
elog(ERROR,"Failed to get status of XID %d",xid);
501+
return true;
497502
}
498503

499504

@@ -1205,7 +1210,7 @@ static void MtmEnableNode(int nodeId)
12051210

12061211
voidMtmRecoveryCompleted(void)
12071212
{
1208-
MTM_LOG1("Recovery of node %d is completed, disabled mask=%lx, reconnect mask=%ld, live nodes=%d",
1213+
MTM_LOG1("Recovery of node %d is completed, disabled mask=%lx, reconnect mask=%lx, live nodes=%d",
12091214
MtmNodeId,Mtm->disabledNodeMask,Mtm->reconnectMask,Mtm->nLiveNodes);
12101215
MtmLock(LW_EXCLUSIVE);
12111216
Mtm->recoverySlot=0;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp