From 8dbacfdfe359f78200578ca52cc687fb1d3d589c Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Fri, 5 Aug 2022 17:42:35 +0800 Subject: [PATCH] refactor(sync): make leader life longer --- source/libs/sync/src/syncRequestVoteReply.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 05a1708b0b..55553d5048 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -125,6 +125,14 @@ int32_t syncNodeOnRequestVoteReplySnapshotCb(SSyncNode* ths, SyncRequestVoteRepl // This tallies votes even when the current state is not Candidate, // but they won't be looked at, so it doesn't matter. if (ths->state == TAOS_SYNC_STATE_CANDIDATE) { + if (ths->pVotesRespond->term != pMsg->term) { + char logBuf[128]; + snprintf(logBuf, sizeof(logBuf), "vote respond error vote-respond-mgr term:%lu, msg term:lu", + ths->pVotesRespond->term, pMsg->term); + syncNodeErrorLog(ths, logBuf); + return -1; + } + votesRespondAdd(ths->pVotesRespond, pMsg); if (pMsg->voteGranted) { // add vote