diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 15861433196237d573cfdb14334dcd1dd27871ac..a269f81ddd73cb9c29ae4900c1ab319cf03af764 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -708,8 +708,8 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) { } setPingTimerMS(pVnode->sync, 5000); - setElectTimerMS(pVnode->sync, 2800); - setHeartbeatTimerMS(pVnode->sync, 900); + setElectTimerMS(pVnode->sync, 4000); + setHeartbeatTimerMS(pVnode->sync, 700); return 0; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 48ebf824e8b5f7ca71874b53c6f8c2e9f61decfc..daa65add3c2e4675c6ae602e55ba9335b82b9b53 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -1270,6 +1270,8 @@ int32_t syncNodeStopElectTimer(SSyncNode* pSyncNode) { atomic_add_fetch_64(&pSyncNode->electTimerLogicClockUser, 1); taosTmrStop(pSyncNode->pElectTimer); pSyncNode->pElectTimer = NULL; + + sTrace("vgId:%d, sync %s stop elect timer", pSyncNode->vgId, syncUtilState2String(pSyncNode->state)); return ret; } @@ -1343,7 +1345,8 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) { atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1); taosTmrStop(pSyncNode->pHeartbeatTimer); pSyncNode->pHeartbeatTimer = NULL; - sTrace("vgId:%d, stop heartbeat timer", pSyncNode->vgId); + + sTrace("vgId:%d, sync %s stop heartbeat timer", pSyncNode->vgId, syncUtilState2String(pSyncNode->state)); return ret; } diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index b47294a8e1c045dfe884528498fbb8154efb8df5..122a81930bec953f167030873ae2ed48bdafc555 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -57,11 +57,14 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { // maybe update term if (pMsg->term > ths->pRaftStore->currentTerm) { + syncNodeUpdateTerm(ths, pMsg->term); +#if 0 if (logOK) { syncNodeUpdateTerm(ths, pMsg->term); } else { syncNodeUpdateTermWithoutStepDown(ths, pMsg->term); } +#endif } ASSERT(pMsg->term <= ths->pRaftStore->currentTerm); @@ -167,11 +170,14 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) { // maybe update term if (pMsg->term > ths->pRaftStore->currentTerm) { + syncNodeUpdateTerm(ths, pMsg->term); +#if 0 if (logOK) { syncNodeUpdateTerm(ths, pMsg->term); } else { syncNodeUpdateTermWithoutStepDown(ths, pMsg->term); } +#endif } ASSERT(pMsg->term <= ths->pRaftStore->currentTerm); diff --git a/source/libs/sync/test/sh/a.sh b/source/libs/sync/test/sh/a.sh index 3983d30b7cf658f4b155d5b90ab8d395886d46bb..f4ffaa50621b0f7c0c859e03a8e1f32c7442b5c4 100644 --- a/source/libs/sync/test/sh/a.sh +++ b/source/libs/sync/test/sh/a.sh @@ -89,7 +89,7 @@ for file in `ls ${logpath}/log.dnode*.vgId*.commit`;do line=`cat ${file} | tail -n1` echo $line | awk '{print $5, $0}' >> ${tmpfile} done -cat ${tmpfile} | sort -k1 > ${logpath}/log.commits +cat ${tmpfile} | sort -k1 | awk 'BEGIN{vgid=$1}{if($1==vgid){print $0}else{print ""; print $0; vgid=$1;}}END{}' > ${logpath}/log.commits exit 0