提交 ba8adb73 编写于 作者: M Minghao Li

refactor(sync): restart elect timer when vote for

上级 eea343c5
...@@ -62,6 +62,8 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { ...@@ -62,6 +62,8 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) {
// maybe has already voted for pMsg->srcId // maybe has already voted for pMsg->srcId
// vote again, no harm // vote again, no harm
raftStoreVote(ths->pRaftStore, &(pMsg->srcId)); raftStoreVote(ths->pRaftStore, &(pMsg->srcId));
syncNodeResetElectTimer(ths);
} }
SyncRequestVoteReply* pReply = syncRequestVoteReplyBuild(ths->vgId); SyncRequestVoteReply* pReply = syncRequestVoteReplyBuild(ths->vgId);
......
...@@ -184,7 +184,7 @@ SWal* createWal(char* path, int32_t vgId) { ...@@ -184,7 +184,7 @@ SWal* createWal(char* path, int32_t vgId) {
return pWal; return pWal;
} }
int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal* pWal, char* path, bool isStandBy) { int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal* pWal, char* path, bool isStandBy, bool enableSnapshot) {
SSyncInfo syncInfo; SSyncInfo syncInfo;
syncInfo.vgId = vgId; syncInfo.vgId = vgId;
syncInfo.msgcb = &gSyncIO->msgcb; syncInfo.msgcb = &gSyncIO->msgcb;
...@@ -194,7 +194,7 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal* ...@@ -194,7 +194,7 @@ int64_t createSyncNode(int32_t replicaNum, int32_t myIndex, int32_t vgId, SWal*
snprintf(syncInfo.path, sizeof(syncInfo.path), "%s_sync_replica%d_index%d", path, replicaNum, myIndex); snprintf(syncInfo.path, sizeof(syncInfo.path), "%s_sync_replica%d_index%d", path, replicaNum, myIndex);
syncInfo.pWal = pWal; syncInfo.pWal = pWal;
syncInfo.isStandBy = isStandBy; syncInfo.isStandBy = isStandBy;
syncInfo.snapshotEnable = true; syncInfo.snapshotEnable = enableSnapshot;
SSyncCfg* pCfg = &syncInfo.syncCfg; SSyncCfg* pCfg = &syncInfo.syncCfg;
...@@ -323,7 +323,7 @@ int main(int argc, char** argv) { ...@@ -323,7 +323,7 @@ int main(int argc, char** argv) {
snprintf(walPath, sizeof(walPath), "%s_wal_replica%d_index%d", gDir, replicaNum, myIndex); snprintf(walPath, sizeof(walPath), "%s_wal_replica%d_index%d", gDir, replicaNum, myIndex);
SWal* pWal = createWal(walPath, gVgId); SWal* pWal = createWal(walPath, gVgId);
int64_t rid = createSyncNode(replicaNum, myIndex, gVgId, pWal, (char*)gDir, isStandBy); int64_t rid = createSyncNode(replicaNum, myIndex, gVgId, pWal, (char*)gDir, isStandBy, enableSnapshot);
assert(rid > 0); assert(rid > 0);
syncStart(rid); syncStart(rid);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册