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;
|
accepted = true;
|
||||||
|
|
||||||
_SEND_RESPONSE:
|
_SEND_RESPONSE:
|
||||||
|
pEntry = NULL;
|
||||||
pReply->matchIndex = syncLogBufferProceed(ths->pLogBuf, ths, &pReply->lastMatchTerm);
|
pReply->matchIndex = syncLogBufferProceed(ths->pLogBuf, ths, &pReply->lastMatchTerm);
|
||||||
bool matched = (pReply->matchIndex >= pReply->lastSendIndex);
|
bool matched = (pReply->matchIndex >= pReply->lastSendIndex);
|
||||||
if (accepted && matched) {
|
if (accepted && matched) {
|
||||||
pReply->success = true;
|
pReply->success = true;
|
||||||
// update commit index only after matching
|
// 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
|
// ack, i.e. send response
|
||||||
|
|
Loading…
Reference in New Issue