fix: use pReply->lastSendIndex instead while updating commitIndex
This commit is contained in:
parent
d307413c36
commit
e22ce2df87
|
@ -207,12 +207,13 @@ int32_t syncNodeOnAppendEntries(SSyncNode* ths, const SRpcMsg* pRpcMsg) {
|
|||
accepted = true;
|
||||
|
||||
_SEND_RESPONSE:
|
||||
pEntry = NULL;
|
||||
pReply->matchIndex = syncLogBufferProceed(ths->pLogBuf, ths, &pReply->lastMatchTerm);
|
||||
bool matched = (pReply->matchIndex >= pReply->lastSendIndex);
|
||||
if (accepted && matched) {
|
||||
pReply->success = true;
|
||||
// update commit index only after matching
|
||||
(void)syncNodeUpdateCommitIndex(ths, TMIN(pMsg->commitIndex, pEntry->index));
|
||||
(void)syncNodeUpdateCommitIndex(ths, TMIN(pMsg->commitIndex, pReply->lastSendIndex));
|
||||
}
|
||||
|
||||
// ack, i.e. send response
|
||||
|
|
Loading…
Reference in New Issue