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

Commit bc2f052

Browse files
committed
Clean up MtmCheckState
1 parent bf6892e commit bc2f052

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

contrib/mmts/state.c

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,18 +108,15 @@ MtmSetClusterStatus(MtmNodeStatus status, char *statusReason)
108108
static void
109109
MtmCheckState(void)
110110
{
111-
// int nVotingNodes = MtmGetNumberOfVotingNodes();
112111
bool isEnabledState;
113112
char *statusReason = "node is disabled by default";
114113
MtmNodeStatus old_status;
115-
int nEnabled = countZeroBits(Mtm->disabledNodeMask, Mtm->nAllNodes);
116-
int nConnected = countZeroBits(SELF_CONNECTIVITY_MASK, Mtm->nAllNodes);
117-
int nReceivers = Mtm->nAllNodes - countZeroBits(Mtm->pglogicalReceiverMask, Mtm->nAllNodes);
118-
int nSenders = Mtm->nAllNodes - countZeroBits(Mtm->pglogicalSenderMask, Mtm->nAllNodes);
114+
int nConnected = countZeroBits(EFFECTIVE_CONNECTIVITY_MASK, Mtm->nAllNodes);
119115

120116
old_status = Mtm->status;
121117

122-
MTM_LOG1("[STATE] Status = (disabled=%s, unaccessible=%s, clique=%s, receivers=%s, senders=%s, total=%i, major=%d, stopped=%s)",
118+
MTM_LOG1("[STATE] %s: (disabled=%s, unaccessible=%s, clique=%s, receivers=%s, senders=%s, total=%i, major=%d, stopped=%s)",
119+
MtmNodeStatusMnem[Mtm->status],
123120
maskToString(Mtm->disabledNodeMask, Mtm->nAllNodes),
124121
maskToString(SELF_CONNECTIVITY_MASK, Mtm->nAllNodes),
125122
maskToString(Mtm->clique, Mtm->nAllNodes),
@@ -192,20 +189,26 @@ MtmCheckState(void)
192189
* in MTM_RECOVERED state.
193190
*/
194191
case MTM_RECOVERED:
195-
if (nReceivers == nEnabled-1 && nSenders == nEnabled-1 && nEnabled == nConnected)
196192
{
197-
/*
198-
* It should be already cleaned by RECOVERY_CAUGHTUP, but
199-
* in major mode or with referee we can be working alone
200-
* so nobody will clean it.
201-
*/
202-
MTM_LOG1("[LOCK] release lock on MTM_RECOVERED switch");
203-
BIT_CLEAR(Mtm->originLockNodeMask, MtmNodeId-1);
204-
MtmSetClusterStatus(MTM_ONLINE, statusReason);
193+
int nEnabled = countZeroBits(Mtm->disabledNodeMask, Mtm->nAllNodes);
194+
int nReceivers = Mtm->nAllNodes - countZeroBits(Mtm->pglogicalReceiverMask, Mtm->nAllNodes);
195+
int nSenders = Mtm->nAllNodes - countZeroBits(Mtm->pglogicalSenderMask, Mtm->nAllNodes);
205196

206-
if (old_status != Mtm->status)
207-
MtmCheckState();
208-
return;
197+
if (nReceivers == nEnabled-1 && nSenders == nEnabled-1 && nEnabled == nConnected)
198+
{
199+
/*
200+
* It should be already cleaned by RECOVERY_CAUGHTUP, but
201+
* in major mode or with referee we can be working alone
202+
* so nobody will clean it.
203+
*/
204+
MTM_LOG1("[LOCK] release lock on MTM_RECOVERED switch");
205+
BIT_CLEAR(Mtm->originLockNodeMask, MtmNodeId-1);
206+
MtmSetClusterStatus(MTM_ONLINE, statusReason);
207+
208+
if (old_status != Mtm->status)
209+
MtmCheckState();
210+
return;
211+
}
209212
}
210213
break;
211214

0 commit comments

Comments
 (0)