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

Commit 10804ed

Browse files
committed
change 3pc logic in case of failure
1 parent ca905f8 commit 10804ed

File tree

1 file changed

+41
-15
lines changed

1 file changed

+41
-15
lines changed

multimaster.c

Lines changed: 41 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,16 +1209,22 @@ MtmVotingCompleted(MtmTransState* ts)
12091209
{
12101210
nodemask_t liveNodesMask = (((nodemask_t)1 << Mtm->nAllNodes) - 1) & ~Mtm->disabledNodeMask & ~((nodemask_t)1 << (MtmNodeId-1));
12111211

1212-
if (!ts->isPrepared) { /* We can not just abort precommitted transactions */
1213-
if (ts->nConfigChanges != Mtm->nConfigChanges)
1212+
if (ts->nConfigChanges != Mtm->nConfigChanges)
1213+
{
1214+
if (MtmGetCurrentStatus() == MTM_ONLINE)
12141215
{
1215-
MTM_ELOG(WARNING, "Abort transaction %s (%llu) because cluster configuration is changed from %d to %d (old mask %llx, new mask %llx) since transaction start",
1216-
ts->gid, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask, liveNodesMask);
1216+
MTM_ELOG(WARNING, "Abort transaction %s {%d} (%llu) because cluster configuration is changed from %d to %d (old mask %llx, new mask %llx) since transaction start",
1217+
ts->gid, ts->status, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask, liveNodesMask);
12171218
MtmAbortTransaction(ts);
12181219
return true;
12191220
}
1220-
/* If cluster configuration was not changed, then node mask should not changed as well */
1221-
Assert(ts->participantsMask == liveNodesMask);
1221+
else
1222+
{
1223+
ts->votingCompleted = true;
1224+
MtmResetTransaction();
1225+
MTM_ELOG(ERROR, "Error out %s {%d} (%llu) because cluster configuration is changed from %d to %d (old mask %llx, new mask %llx) since transaction start and we aren't online",
1226+
ts->gid, ts->status, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask, liveNodesMask);
1227+
}
12221228
}
12231229

12241230
if (ts->votingCompleted) {
@@ -1369,10 +1375,20 @@ MtmPostPrepareTransaction(MtmCurrentTrans* x)
13691375
/* recheck under lock that nothing is changed */
13701376
if (ts->nConfigChanges != Mtm->nConfigChanges)
13711377
{
1372-
MTM_ELOG(WARNING, "XX Abort transaction %s (%llu) because cluster configuration is changed from %d to %d (old mask %llx) since transaction start",
1373-
ts->gid, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask);
1374-
MtmAbortTransaction(ts);
1375-
x->status = TRANSACTION_STATUS_ABORTED;
1378+
if (Mtm->status == MTM_ONLINE)
1379+
{
1380+
MTM_ELOG(WARNING, "XX Abort transaction %s {%d} (%llu) because cluster configuration is changed from %d to %d (old mask %llx) since transaction start",
1381+
ts->gid, ts->status, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask);
1382+
MtmAbortTransaction(ts);
1383+
x->status = TRANSACTION_STATUS_ABORTED;
1384+
}
1385+
else
1386+
{
1387+
ts->votingCompleted = true;
1388+
MtmResetTransaction();
1389+
MTM_ELOG(ERROR, "Error out %s {%d} (%llu) because cluster configuration is changed from %d to %d (old mask %llx) since transaction start and we aren't online",
1390+
ts->gid, ts->status, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask);
1391+
}
13761392
}
13771393
} else {
13781394
ts->status = TRANSACTION_STATUS_UNKNOWN;
@@ -1451,10 +1467,20 @@ MtmPreCommitPreparedTransaction(MtmCurrentTrans* x)
14511467
/* recheck under lock that nothing is changed */
14521468
if (ts->nConfigChanges != Mtm->nConfigChanges)
14531469
{
1454-
MTM_ELOG(WARNING, "X Abort transaction %s (%llu) because cluster configuration is changed from %d to %d (old mask %llx) since transaction start",
1455-
ts->gid, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask);
1456-
MtmAbortTransaction(ts);
1457-
x->status = TRANSACTION_STATUS_ABORTED;
1470+
if (Mtm->status == MTM_ONLINE)
1471+
{
1472+
MTM_ELOG(WARNING, "X Abort transaction %s (%llu) because cluster configuration is changed from %d to %d (old mask %llx) since transaction start",
1473+
ts->gid, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask);
1474+
MtmAbortTransaction(ts);
1475+
x->status = TRANSACTION_STATUS_ABORTED;
1476+
}
1477+
else
1478+
{
1479+
ts->votingCompleted = true;
1480+
MtmResetTransaction();
1481+
MTM_ELOG(ERROR, "Error out %s (%llu) because cluster configuration is changed from %d to %d (old mask %llx) since transaction start and we aren't online",
1482+
ts->gid, (long64)ts->xid, ts->nConfigChanges, Mtm->nConfigChanges, ts->participantsMask);
1483+
}
14581484
}
14591485
} else {
14601486
ts->status = TRANSACTION_STATUS_UNKNOWN;
@@ -2030,7 +2056,7 @@ MtmPollStatusOfPreparedTransactions(bool majorMode)
20302056

20312057
if (majorMode)
20322058
{
2033-
MtmFinishPreparedTransaction(ts, false);
2059+
MtmFinishPreparedTransaction(ts, ts->status == TRANSACTION_STATUS_UNKNOWN);
20342060
}
20352061
else
20362062
{

0 commit comments

Comments
 (0)