Merge pull request #24174 from taosdata/FIX/TD-28001-3.0
enh: protect syncNodeRestore with log buffer mutex
This commit is contained in:
commit
40994c3fbd
|
@ -1162,9 +1162,12 @@ int32_t syncNodeRestore(SSyncNode* pSyncNode) {
|
||||||
ASSERTS(pSyncNode->pLogStore != NULL, "log store not created");
|
ASSERTS(pSyncNode->pLogStore != NULL, "log store not created");
|
||||||
ASSERTS(pSyncNode->pLogBuf != NULL, "ring log buffer not created");
|
ASSERTS(pSyncNode->pLogBuf != NULL, "ring log buffer not created");
|
||||||
|
|
||||||
|
taosThreadMutexLock(&pSyncNode->pLogBuf->mutex);
|
||||||
SyncIndex lastVer = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
|
SyncIndex lastVer = pSyncNode->pLogStore->syncLogLastIndex(pSyncNode->pLogStore);
|
||||||
SyncIndex commitIndex = pSyncNode->pLogStore->syncLogCommitIndex(pSyncNode->pLogStore);
|
SyncIndex commitIndex = pSyncNode->pLogStore->syncLogCommitIndex(pSyncNode->pLogStore);
|
||||||
SyncIndex endIndex = pSyncNode->pLogBuf->endIndex;
|
SyncIndex endIndex = pSyncNode->pLogBuf->endIndex;
|
||||||
|
taosThreadMutexUnlock(&pSyncNode->pLogBuf->mutex);
|
||||||
|
|
||||||
if (lastVer != -1 && endIndex != lastVer + 1) {
|
if (lastVer != -1 && endIndex != lastVer + 1) {
|
||||||
terrno = TSDB_CODE_WAL_LOG_INCOMPLETE;
|
terrno = TSDB_CODE_WAL_LOG_INCOMPLETE;
|
||||||
sError("vgId:%d, failed to restore sync node since %s. expected lastLogIndex:%" PRId64 ", lastVer:%" PRId64 "",
|
sError("vgId:%d, failed to restore sync node since %s. expected lastLogIndex:%" PRId64 ", lastVer:%" PRId64 "",
|
||||||
|
|
Loading…
Reference in New Issue