Tencent / phxpaxos

The Paxos library implemented in C++ that has been used in the WeChat production environment.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

用户写请求,提交了上次选主超时的value,导致主的租约为0,出现失主现象

liluo1990 opened this issue · comments

用户写请求,提交了上次选主超时的value,这个时候pAbsMasterTimeout ==0 ,传入 LearnMaster函数的时候,如果自己是主,则设置m_llAbsExpireTime = 0,这个逻辑就会出现主节点失主的情况。

函数片段:
MasterStateMachine :: Execute

   uint64_t * pAbsMasterTimeout = nullptr;
    if (poSMCtx != nullptr && poSMCtx->m_pCtx != nullptr)
    {
        pAbsMasterTimeout = (uint64_t *)poSMCtx->m_pCtx;
    }

    uint64_t llAbsMasterTimeout = pAbsMasterTimeout != nullptr ? *pAbsMasterTimeout : 0;

    PLG1Imp("absmaster timeout %lu", llAbsMasterTimeout);

    int ret = LearnMaster(llInstanceID, oMasterOper, llAbsMasterTimeout);
    if (ret != 0)
    {
        return false;
    }

MasterStateMachine :: LearnMaster

if (m_iMasterNodeID == m_iMyNodeID)
{
//self be master
//use local abstimeout
m_llAbsExpireTime = llAbsMasterTimeout;
BP->GetMasterBP()->SuccessBeMaster();
PLG1Head("Be master success, absexpiretime %lu", m_llAbsExpireTime);
}