fix:remove-lock-from-log-sync-heartbeat
This commit is contained in:
parent
61a4c41332
commit
fde07fff88
|
@ -35,6 +35,7 @@ void raftStoreClearVote(SSyncNode *pNode);
|
||||||
void raftStoreNextTerm(SSyncNode *pNode);
|
void raftStoreNextTerm(SSyncNode *pNode);
|
||||||
void raftStoreSetTerm(SSyncNode *pNode, SyncTerm term);
|
void raftStoreSetTerm(SSyncNode *pNode, SyncTerm term);
|
||||||
SyncTerm raftStoreGetTerm(SSyncNode *pNode);
|
SyncTerm raftStoreGetTerm(SSyncNode *pNode);
|
||||||
|
SyncTerm raftStoreTryGetTerm(SSyncNode *pNode);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,3 +213,13 @@ SyncTerm raftStoreGetTerm(SSyncNode *pNode) {
|
||||||
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||||
return term;
|
return term;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SyncTerm raftStoreTryGetTerm(SSyncNode *pNode) {
|
||||||
|
SyncTerm term = 0;
|
||||||
|
if (taosThreadMutexTryLock(&pNode->raftStore.mutex) == 0) {
|
||||||
|
term = pNode->raftStore.currentTerm;
|
||||||
|
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return term;
|
||||||
|
}
|
||||||
|
|
|
@ -286,7 +286,7 @@ void syncPrintNodeLog(const char* flags, ELogLevel level, int32_t dflag, bool fo
|
||||||
void syncPrintHbLog(const char* flags, ELogLevel level, int32_t dflag, bool formatTime, SSyncNode* pNode,
|
void syncPrintHbLog(const char* flags, ELogLevel level, int32_t dflag, bool formatTime, SSyncNode* pNode,
|
||||||
const char* format, ...) {
|
const char* format, ...) {
|
||||||
if (pNode == NULL || pNode->pLogStore == NULL) return;
|
if (pNode == NULL || pNode->pLogStore == NULL) return;
|
||||||
int64_t currentTerm = raftStoreGetTerm(pNode);
|
int64_t currentTerm = raftStoreTryGetTerm(pNode);
|
||||||
|
|
||||||
// save error code, otherwise it will be overwritten
|
// save error code, otherwise it will be overwritten
|
||||||
int32_t errCode = terrno;
|
int32_t errCode = terrno;
|
||||||
|
@ -467,17 +467,24 @@ void syncLogRecvAppendEntriesReply(SSyncNode* pSyncNode, const SyncAppendEntries
|
||||||
|
|
||||||
void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool printX, int64_t timerElapsed,
|
void syncLogSendHeartbeat(SSyncNode* pSyncNode, const SyncHeartbeat* pMsg, bool printX, int64_t timerElapsed,
|
||||||
int64_t execTime) {
|
int64_t execTime) {
|
||||||
if (printX) {
|
if (sDebugFlag & DEBUG_TRACE) {
|
||||||
sHTrace(pSyncNode,
|
char pBuf[TD_TIME_STR_LEN] = {0};
|
||||||
"send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
|
if (pMsg->timeStamp > 0) {
|
||||||
", ts:%" PRId64 "}, x",
|
if (formatTimestampLocal(pBuf, pMsg->timeStamp, TSDB_TIME_PRECISION_MILLI) == NULL) {
|
||||||
DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp);
|
pBuf[0] = '\0';
|
||||||
} else {
|
}
|
||||||
sHTrace(pSyncNode,
|
}
|
||||||
"send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
|
if (printX) {
|
||||||
", ts:%" PRId64 "}, timer-elapsed:%" PRId64 ", next-exec:%" PRId64,
|
sHTrace(pSyncNode,
|
||||||
DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, timerElapsed,
|
"send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
|
||||||
execTime);
|
", ts:%s}, x",
|
||||||
|
DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pBuf);
|
||||||
|
} else {
|
||||||
|
sHTrace(pSyncNode,
|
||||||
|
"send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
|
||||||
|
", ts:%s}, timer-elapsed:%" PRId64 ", next-exec:%" PRId64,
|
||||||
|
DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pBuf, timerElapsed, execTime);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,6 +48,7 @@ class TDTestCase:
|
||||||
tdSql.checkData(4,1,'%s:6430'%self.host)
|
tdSql.checkData(4,1,'%s:6430'%self.host)
|
||||||
tdSql.checkData(0,4,'ready')
|
tdSql.checkData(0,4,'ready')
|
||||||
tdSql.checkData(4,4,'ready')
|
tdSql.checkData(4,4,'ready')
|
||||||
|
time.sleep(1)
|
||||||
tdSql.query("select * from information_schema.ins_mnodes;")
|
tdSql.query("select * from information_schema.ins_mnodes;")
|
||||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||||
tdSql.checkData(0,2,'leader')
|
tdSql.checkData(0,2,'leader')
|
||||||
|
|
|
@ -42,6 +42,7 @@ class TDTestCase:
|
||||||
return buildPath
|
return buildPath
|
||||||
|
|
||||||
def check_setup_cluster_status(self):
|
def check_setup_cluster_status(self):
|
||||||
|
time.sleep(1)
|
||||||
tdSql.query("select * from information_schema.ins_mnodes")
|
tdSql.query("select * from information_schema.ins_mnodes")
|
||||||
for mnode in tdSql.queryResult:
|
for mnode in tdSql.queryResult:
|
||||||
name = mnode[1]
|
name = mnode[1]
|
||||||
|
|
Loading…
Reference in New Issue