From 16e6273d9d429fad788aacd1e43aa4fa05969493 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Tue, 25 Oct 2022 20:31:20 +0800 Subject: [PATCH] refactor(sync): delete assert --- source/libs/sync/src/syncVoteMgr.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 39d62b957a..ce72935221 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -66,7 +66,12 @@ bool voteGrantedMajority(SVotesGranted *pVotesGranted) { void voteGrantedVote(SVotesGranted *pVotesGranted, SyncRequestVoteReply *pMsg) { ASSERT(pMsg->voteGranted == true); - ASSERT(pMsg->term == pVotesGranted->term); + + if (pMsg->term != pVotesGranted->term) { + syncNodeEventLog(pVotesGranted->pSyncNode, "vote grant vnode error"); + return; + } + ASSERT(syncUtilSameId(&pVotesGranted->pSyncNode->myRaftId, &pMsg->destId)); int j = -1; @@ -201,7 +206,11 @@ bool votesResponded(SVotesRespond *pVotesRespond, const SRaftId *pRaftId) { } void votesRespondAdd(SVotesRespond *pVotesRespond, const SyncRequestVoteReply *pMsg) { - ASSERT(pVotesRespond->term == pMsg->term); + if (pVotesRespond->term != pMsg->term) { + syncNodeEventLog(pVotesRespond->pSyncNode, "vote respond add error"); + return; + } + for (int i = 0; i < pVotesRespond->replicaNum; ++i) { if (syncUtilSameId(&((*(pVotesRespond->replicas))[i]), &pMsg->srcId)) { // ASSERT(pVotesRespond->isRespond[i] == false);