phxpaxos icon indicating copy to clipboard operation
phxpaxos copied to clipboard

why AskforCheckpoint don't use lock?

Open fishfreetaken opened this issue 5 years ago • 1 comments

if I have 5 nodes, the node 5th need to get the checkpoint. When the 5th receive three node checkpoint's ack (for example :1,2,3), 3th node is ready to transmit its checkpoint and jump into begin, but now 5th node receive 4th checkpoint's ack and 4th also goes into begin states to transmit its checkpoint. In such case, 4th node will override 3th node checkpoint. My question is how to avoid it? I can't find the result in source code. Please release me!!!!! Thank you!

fishfreetaken avatar Aug 21 '19 14:08 fishfreetaken

have you figured it out ? I think i might got an answer after reading the source code of learner and checkpoint_sender. Before asking for checkpoint from a learnee, a learner must first enter askforcheckpoint mode,which is judged by past the majoritycount of paxosgroup. code int cp_mgr:PrepareForAskforCheckpoint `if (llNowTime > m_llLastAskforCheckpointTime + 60000) { PLGImp("no majority reply, just ask for checkpoint"); } else {

    if ((int)m_setNeedAsk.size() < m_poConfig->GetMajorityCount())
    {
        PLGImp("Need more other tell us need to AskForCheckpoint");
        return -2;
    }
}

m_llLastAskforCheckpointTime = 0; m_bInAskforCheckpointMode = true;`

And only if one learner enters into this "m_bInAskforCheckpointMode",then it will send a askforcheckpoint request to a single node,which will successfully build a checkpoint transport between learner and learnee,through the mechanism of send and ack of checkpoint sequence

drusong avatar Dec 18 '19 10:12 drusong