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

refactor(sync): add log

上级 2c386922
......@@ -35,7 +35,7 @@
#include "syncVoteMgr.h"
#include "tref.h"
bool gRaftDetailLog = false;
bool gRaftDetailLog = true;
static int32_t tsNodeRefId = -1;
......@@ -1155,6 +1155,8 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) {
}
void syncNodeBecomeFollower(SSyncNode* pSyncNode) {
sInfo("sync event become follower");
// maybe clear leader cache
if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) {
pSyncNode->leaderCache = EMPTY_RAFT_ID;
......@@ -1187,6 +1189,8 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode) {
// /\ UNCHANGED <<messages, currentTerm, votedFor, candidateVars, logVars>>
//
void syncNodeBecomeLeader(SSyncNode* pSyncNode) {
sInfo("sync event become leader");
// state change
pSyncNode->state = TAOS_SYNC_STATE_LEADER;
......
......@@ -14,6 +14,7 @@
*/
#include "syncRaftLog.h"
#include "syncRaftCfg.h"
#include "wal.h"
// refactor, log[0 .. n] ==> log[m .. n]
......@@ -161,7 +162,9 @@ static int32_t raftLogAppendEntry(struct SSyncLogStore* pLogStore, SSyncRaftEntr
walFsync(pWal, true);
sTrace("sync event write index:%" PRId64, pEntry->index);
sTrace("sync event write index:%ld, %s, isStandBy:%d, msgType:%s, originalRpcType:%s", pEntry->index,
syncUtilState2String(pData->pSyncNode->state), pData->pSyncNode->pRaftCfg->isStandBy,
TMSG_INFO(pEntry->msgType), TMSG_INFO(pEntry->originalRpcType));
return code;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册