Open liluo1990 opened 4 years ago
用户写请求,提交了上次选主超时的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); }
用户写请求,提交了上次选主超时的value,这个时候pAbsMasterTimeout ==0 ,传入 LearnMaster函数的时候,如果自己是主,则设置m_llAbsExpireTime = 0,这个逻辑就会出现主节点失主的情况。
函数片段: MasterStateMachine :: Execute
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); }