fix/remove-sync-heartbeat-lock
This commit is contained in:
parent
58b4c6b47e
commit
6bfa1acaeb
|
@ -40,6 +40,7 @@ typedef struct SSyncLogReplMgr {
|
|||
int32_t retryBackoff;
|
||||
int32_t peerId;
|
||||
int32_t sendCount;
|
||||
TdThreadMutex mutex;
|
||||
} SSyncLogReplMgr;
|
||||
|
||||
typedef struct SSyncLogBufEntry {
|
||||
|
|
|
@ -1140,26 +1140,29 @@ int32_t syncLogReplRecover(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEn
|
|||
|
||||
int32_t syncLogReplProcessHeartbeatReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncHeartbeatReply* pMsg) {
|
||||
SSyncLogBuffer* pBuf = pNode->pLogBuf;
|
||||
(void)taosThreadMutexLock(&pBuf->mutex);
|
||||
(void)taosThreadMutexLock(&pMgr->mutex);
|
||||
if (pMsg->startTime != 0 && pMsg->startTime != pMgr->peerStartTime) {
|
||||
sInfo("vgId:%d, reset sync log repl in heartbeat. peer:%" PRIx64 ", start time:%" PRId64 ", old:%" PRId64 "",
|
||||
pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime);
|
||||
syncLogReplReset(pMgr);
|
||||
pMgr->peerStartTime = pMsg->startTime;
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pBuf->mutex);
|
||||
(void)taosThreadMutexUnlock(&pMgr->mutex);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t syncLogReplProcessReply(SSyncLogReplMgr* pMgr, SSyncNode* pNode, SyncAppendEntriesReply* pMsg) {
|
||||
SSyncLogBuffer* pBuf = pNode->pLogBuf;
|
||||
(void)taosThreadMutexLock(&pBuf->mutex);
|
||||
(void)taosThreadMutexLock(&pMgr->mutex);
|
||||
if (pMsg->startTime != pMgr->peerStartTime) {
|
||||
sInfo("vgId:%d, reset sync log repl in appendlog reply. peer:%" PRIx64 ", start time:%" PRId64 ", old:%" PRId64,
|
||||
pNode->vgId, pMsg->srcId.addr, pMsg->startTime, pMgr->peerStartTime);
|
||||
syncLogReplReset(pMgr);
|
||||
pMgr->peerStartTime = pMsg->startTime;
|
||||
}
|
||||
(void)taosThreadMutexUnlock(&pMgr->mutex);
|
||||
|
||||
(void)taosThreadMutexLock(&pBuf->mutex);
|
||||
|
||||
int32_t code = 0;
|
||||
if (pMgr->restored) {
|
||||
|
@ -1324,6 +1327,12 @@ SSyncLogReplMgr* syncLogReplCreate() {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
int32_t code = taosThreadMutexInit(&pMgr->mutex, NULL);
|
||||
if (code) {
|
||||
terrno = code;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pMgr;
|
||||
}
|
||||
|
||||
|
@ -1331,6 +1340,7 @@ void syncLogReplDestroy(SSyncLogReplMgr* pMgr) {
|
|||
if (pMgr == NULL) {
|
||||
return;
|
||||
}
|
||||
taosThreadMutexDestroy(&pMgr->mutex);
|
||||
taosMemoryFree(pMgr);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue