Tencent / phxpaxos

The Paxos library implemented in C++ that has been used in the WeChat production environment.
Other
3.36k stars 863 forks source link

如果提议发生三次冲突,默认算成功? #201

Open 315567599 opened 1 week ago

315567599 commented 1 week ago

重试三次,如果都冲突,则返回成功?!

int Committer :: NewValueGetID(const std::string & sValue, uint64_t & llInstanceID, SMCtx * poSMCtx)

{ BP->GetCommiterBP()->NewValue();

int iRetryCount = 3;
int ret = PaxosTryCommitRet_OK;
while(iRetryCount--)
{
    TimeStat oTimeStat;
    oTimeStat.Point();

    ret = NewValueGetIDNoRetry(sValue, llInstanceID, poSMCtx);
    if (ret != PaxosTryCommitRet_Conflict)
    {
        if (ret == 0)
        {
            BP->GetCommiterBP()->NewValueCommitOK(oTimeStat.Point());
        }
        else
        {
            BP->GetCommiterBP()->NewValueCommitFail();
        }
        break;
    }

    BP->GetCommiterBP()->NewValueConflict();

    if (poSMCtx != nullptr && poSMCtx->m_iSMID == MASTER_V_SMID)
    {
        //master sm not retry
        break;
    }
}

return ret;

}