Merge pull request #18732 from taosdata/FIX/TD-20920-3.0

fix: synchronize access of pWalHandle with mutex in raftLogGetEntry
This commit is contained in:
Shengliang Guan 2022-12-06 14:13:45 +08:00 committed by GitHub
commit d90b58b55d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -234,18 +234,17 @@ int32_t raftLogGetEntry(struct SSyncLogStore* pLogStore, SyncIndex index, SSyncR
*ppEntry = NULL;
// SWalReadHandle* pWalHandle = walOpenReadHandle(pWal);
int64_t ts1 = taosGetTimestampNs();
taosThreadMutexLock(&(pData->mutex));
SWalReader* pWalHandle = pData->pWalHandle;
if (pWalHandle == NULL) {
terrno = TSDB_CODE_SYN_INTERNAL_ERROR;
sError("vgId:%d, wal handle is NULL", pData->pSyncNode->vgId);
taosThreadMutexUnlock(&(pData->mutex));
return -1;
}
int64_t ts1 = taosGetTimestampNs();
taosThreadMutexLock(&(pData->mutex));
int64_t ts2 = taosGetTimestampNs();
code = walReadVer(pWalHandle, index);
int64_t ts3 = taosGetTimestampNs();