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 raftStoreSetTerm(SSyncNode *pNode, SyncTerm term);
|
||||
SyncTerm raftStoreGetTerm(SSyncNode *pNode);
|
||||
SyncTerm raftStoreTryGetTerm(SSyncNode *pNode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -213,3 +213,13 @@ SyncTerm raftStoreGetTerm(SSyncNode *pNode) {
|
|||
(void)taosThreadMutexUnlock(&pNode->raftStore.mutex);
|
||||
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,
|
||||
const char* format, ...) {
|
||||
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
|
||||
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,
|
||||
int64_t execTime) {
|
||||
if (printX) {
|
||||
sHTrace(pSyncNode,
|
||||
"send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
|
||||
", ts:%" PRId64 "}, x",
|
||||
DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp);
|
||||
} else {
|
||||
sHTrace(pSyncNode,
|
||||
"send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
|
||||
", ts:%" PRId64 "}, timer-elapsed:%" PRId64 ", next-exec:%" PRId64,
|
||||
DID(&pMsg->destId), pMsg->term, pMsg->commitIndex, pMsg->minMatchIndex, pMsg->timeStamp, timerElapsed,
|
||||
execTime);
|
||||
if (sDebugFlag & DEBUG_TRACE) {
|
||||
char pBuf[TD_TIME_STR_LEN] = {0};
|
||||
if (pMsg->timeStamp > 0) {
|
||||
if (formatTimestampLocal(pBuf, pMsg->timeStamp, TSDB_TIME_PRECISION_MILLI) == NULL) {
|
||||
pBuf[0] = '\0';
|
||||
}
|
||||
}
|
||||
if (printX) {
|
||||
sHTrace(pSyncNode,
|
||||
"send sync-heartbeat to dnode:%d {term:%" PRId64 ", commit-index:%" PRId64 ", min-match:%" PRId64
|
||||
", 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(0,4,'ready')
|
||||
tdSql.checkData(4,4,'ready')
|
||||
time.sleep(1)
|
||||
tdSql.query("select * from information_schema.ins_mnodes;")
|
||||
tdSql.checkData(0,1,'%s:6030'%self.host)
|
||||
tdSql.checkData(0,2,'leader')
|
||||
|
|
|
@ -42,6 +42,7 @@ class TDTestCase:
|
|||
return buildPath
|
||||
|
||||
def check_setup_cluster_status(self):
|
||||
time.sleep(1)
|
||||
tdSql.query("select * from information_schema.ins_mnodes")
|
||||
for mnode in tdSql.queryResult:
|
||||
name = mnode[1]
|
||||
|
|
Loading…
Reference in New Issue