Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit cbdb2d1

Browse files
committed
Always access Raftable with infinite timeout
1 parent 45a33b4 commit cbdb2d1

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

contrib/mmts/multimaster.c

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,41 +1378,38 @@ bool MtmRefreshClusterStatus(bool nowait)
13781378
MTM_LOG1("Find clique %lx, disabledNodeMask %lx", (long) clique, (long) Mtm->disabledNodeMask);
13791379
MtmLock(LW_EXCLUSIVE);
13801380
disabled = ~clique & (((nodemask_t)1 << Mtm->nAllNodes)-1) & ~Mtm->disabledNodeMask; /* new disabled nodes mask */
1381+
enabled = clique & Mtm->disabledNodeMask; /* new enabled nodes mask */
13811382

1382-
mask = disabled;
1383-
for (i = 0; mask != 0; i++, mask >>= 1) {
1383+
for (i = 0, mask = disabled; mask != 0; i++, mask >>= 1) {
13841384
if (mask & 1) {
13851385
MtmDisableNode(i+1);
13861386
}
13871387
}
13881388

1389-
enabled = clique & Mtm->disabledNodeMask; /* new enabled nodes mask */
1390-
1391-
mask = enabled;
1392-
for (i = 0; mask != 0; i++, mask >>= 1) {
1389+
for (i = 0, mask = enabled; mask != 0; i++, mask >>= 1) {
13931390
if (mask & 1) {
13941391
MtmEnableNode(i+1);
13951392
}
13961393
}
13971394
if (disabled|enabled) {
13981395
MtmCheckQuorum();
1399-
/* Interrupt voting for active transaction and abort them */
1400-
for (ts = Mtm->transListHead; ts != NULL; ts = ts->next) {
1401-
MTM_LOG3("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d",
1402-
ts->gid, ts->gtid.node, ts->xid, ts->status, ts->gtid.xid);
1403-
if (MtmIsCoordinator(ts)) {
1404-
if (!ts->votingCompleted && ts->status != TRANSACTION_STATUS_ABORTED) {
1396+
}
1397+
/* Interrupt voting for active transaction and abort them */
1398+
for (ts = Mtm->transListHead; ts != NULL; ts = ts->next) {
1399+
MTM_LOG3("Active transaction gid='%s', coordinator=%d, xid=%d, status=%d, gtid.xid=%d",
1400+
ts->gid, ts->gtid.node, ts->xid, ts->status, ts->gtid.xid);
1401+
if (MtmIsCoordinator(ts)) {
1402+
if (!ts->votingCompleted && (disabled|enabled) != 0 && ts->status != TRANSACTION_STATUS_ABORTED) {
1403+
MtmAbortTransaction(ts);
1404+
MtmWakeUpBackend(ts);
1405+
}
1406+
} else if (TransactionIdIsValid(ts->gtid.xid) && BIT_CHECK(disabled, ts->gtid.node-1)) { // coordinator of transaction is on disabled node
1407+
if (ts->gid[0]) {
1408+
if (ts->status == TRANSACTION_STATUS_UNKNOWN || ts->status == TRANSACTION_STATUS_IN_PROGRESS) {
1409+
MTM_LOG1("%d: Abort trasaction %s because its coordinator is at disabled node %d", MyProcPid, ts->gid, ts->gtid.node);
14051410
MtmAbortTransaction(ts);
1406-
MtmWakeUpBackend(ts);
1407-
}
1408-
} else if (TransactionIdIsValid(ts->gtid.xid) && BIT_CHECK(disabled, ts->gtid.node-1)) { // coordinator of transaction is on disabled node
1409-
if (ts->gid[0]) {
1410-
if (ts->status == TRANSACTION_STATUS_UNKNOWN || ts->status == TRANSACTION_STATUS_IN_PROGRESS) {
1411-
MTM_LOG1("%d: Abort trasaction %s because its coordinator is at disabled node %d", MyProcPid, ts->gid, ts->gtid.node);
1412-
MtmAbortTransaction(ts);
1413-
MtmTx.status = TRANSACTION_STATUS_ABORTED; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1414-
FinishPreparedTransaction(ts->gid, false);
1415-
}
1411+
MtmTx.status = TRANSACTION_STATUS_ABORTED; /* prevent recursive invocation of MtmAbortPreparedTransaction */
1412+
FinishPreparedTransaction(ts->gid, false);
14161413
}
14171414
}
14181415
}
@@ -1491,7 +1488,7 @@ void MtmOnNodeDisconnect(int nodeId)
14911488
}
14921489
MtmUnlock();
14931490
} else {
1494-
MtmRefreshClusterStatus(true); /* false); -- TODO: raftable can handg in nowait=true */
1491+
MtmRefreshClusterStatus(false);
14951492
}
14961493
}
14971494

@@ -2684,7 +2681,7 @@ Datum mtm_dump_lock_graph(PG_FUNCTION_ARGS)
26842681
for (i = 0; i < Mtm->nAllNodes; i++)
26852682
{
26862683
size_t size;
2687-
char *data = RaftableGet(psprintf("lock-graph-%d", i+1), &size, NULL, true);
2684+
char *data = RaftableGet(psprintf("lock-graph-%d", i+1), &size, NULL, false);
26882685
if (data) {
26892686
GlobalTransactionId *gtid = (GlobalTransactionId *)data;
26902687
GlobalTransactionId *last = (GlobalTransactionId *)(data + size);
@@ -3308,7 +3305,7 @@ MtmDetectGlobalDeadLock(PGPROC* proc)
33083305
for (i = 0; i < Mtm->nAllNodes; i++) {
33093306
if (i+1 != MtmNodeId && !BIT_CHECK(Mtm->disabledNodeMask, i)) {
33103307
size_t size;
3311-
void* data = RaftableGet(psprintf("lock-graph-%d", i+1), &size, NULL, true);
3308+
void* data = RaftableGet(psprintf("lock-graph-%d", i+1), &size, NULL, false);
33123309
if (data == NULL) {
33133310
return true; /* If using Raftable is disabled */
33143311
} else {

0 commit comments

Comments
 (0)