From 577a203541a8152be54fb632ce392a11da6b04ac Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Tue, 6 Dec 2022 12:50:59 +0800 Subject: [PATCH] fix: synchronize access of pWalHandle with mutex in raftLogGetEntry --- source/libs/sync/src/syncRaftLog.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index f51fe344df..018ac5bb7d 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -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(); -- GitLab