refactor(sync): make leader life longer
This commit is contained in:
parent
7d50c26207
commit
e628b70726
|
@ -708,8 +708,8 @@ int32_t vnodeSyncOpen(SVnode *pVnode, char *path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
setPingTimerMS(pVnode->sync, 5000);
|
setPingTimerMS(pVnode->sync, 5000);
|
||||||
setElectTimerMS(pVnode->sync, 2800);
|
setElectTimerMS(pVnode->sync, 4000);
|
||||||
setHeartbeatTimerMS(pVnode->sync, 900);
|
setHeartbeatTimerMS(pVnode->sync, 700);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1270,6 +1270,8 @@ int32_t syncNodeStopElectTimer(SSyncNode* pSyncNode) {
|
||||||
atomic_add_fetch_64(&pSyncNode->electTimerLogicClockUser, 1);
|
atomic_add_fetch_64(&pSyncNode->electTimerLogicClockUser, 1);
|
||||||
taosTmrStop(pSyncNode->pElectTimer);
|
taosTmrStop(pSyncNode->pElectTimer);
|
||||||
pSyncNode->pElectTimer = NULL;
|
pSyncNode->pElectTimer = NULL;
|
||||||
|
|
||||||
|
sTrace("vgId:%d, sync %s stop elect timer", pSyncNode->vgId, syncUtilState2String(pSyncNode->state));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1343,7 +1345,8 @@ int32_t syncNodeStopHeartbeatTimer(SSyncNode* pSyncNode) {
|
||||||
atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1);
|
atomic_add_fetch_64(&pSyncNode->heartbeatTimerLogicClockUser, 1);
|
||||||
taosTmrStop(pSyncNode->pHeartbeatTimer);
|
taosTmrStop(pSyncNode->pHeartbeatTimer);
|
||||||
pSyncNode->pHeartbeatTimer = NULL;
|
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;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,11 +57,14 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) {
|
||||||
|
|
||||||
// maybe update term
|
// maybe update term
|
||||||
if (pMsg->term > ths->pRaftStore->currentTerm) {
|
if (pMsg->term > ths->pRaftStore->currentTerm) {
|
||||||
|
syncNodeUpdateTerm(ths, pMsg->term);
|
||||||
|
#if 0
|
||||||
if (logOK) {
|
if (logOK) {
|
||||||
syncNodeUpdateTerm(ths, pMsg->term);
|
syncNodeUpdateTerm(ths, pMsg->term);
|
||||||
} else {
|
} else {
|
||||||
syncNodeUpdateTermWithoutStepDown(ths, pMsg->term);
|
syncNodeUpdateTermWithoutStepDown(ths, pMsg->term);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ASSERT(pMsg->term <= ths->pRaftStore->currentTerm);
|
ASSERT(pMsg->term <= ths->pRaftStore->currentTerm);
|
||||||
|
|
||||||
|
@ -167,11 +170,14 @@ int32_t syncNodeOnRequestVoteSnapshotCb(SSyncNode* ths, SyncRequestVote* pMsg) {
|
||||||
|
|
||||||
// maybe update term
|
// maybe update term
|
||||||
if (pMsg->term > ths->pRaftStore->currentTerm) {
|
if (pMsg->term > ths->pRaftStore->currentTerm) {
|
||||||
|
syncNodeUpdateTerm(ths, pMsg->term);
|
||||||
|
#if 0
|
||||||
if (logOK) {
|
if (logOK) {
|
||||||
syncNodeUpdateTerm(ths, pMsg->term);
|
syncNodeUpdateTerm(ths, pMsg->term);
|
||||||
} else {
|
} else {
|
||||||
syncNodeUpdateTermWithoutStepDown(ths, pMsg->term);
|
syncNodeUpdateTermWithoutStepDown(ths, pMsg->term);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
ASSERT(pMsg->term <= ths->pRaftStore->currentTerm);
|
ASSERT(pMsg->term <= ths->pRaftStore->currentTerm);
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ for file in `ls ${logpath}/log.dnode*.vgId*.commit`;do
|
||||||
line=`cat ${file} | tail -n1`
|
line=`cat ${file} | tail -n1`
|
||||||
echo $line | awk '{print $5, $0}' >> ${tmpfile}
|
echo $line | awk '{print $5, $0}' >> ${tmpfile}
|
||||||
done
|
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
|
exit 0
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue