diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index 51307dc17d10821d126e030e22270206af650ba4..db31692da9d4fd0be1f0b031adddd135a853b79f 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -635,6 +635,7 @@ int32_t walWrite(SWal *pWal, int64_t index, tmsg_t msgType, const void *body, in } void walFsync(SWal *pWal, bool forceFsync) { + taosThreadMutexLock(&pWal->mutex); if (forceFsync || (pWal->cfg.level == TAOS_WAL_FSYNC && pWal->cfg.fsyncPeriod == 0)) { wTrace("vgId:%d, fileId:%" PRId64 ".idx, do fsync", pWal->cfg.vgId, walGetCurFileFirstVer(pWal)); if (taosFsyncFile(pWal->pIdxFile) < 0) { @@ -647,4 +648,5 @@ void walFsync(SWal *pWal, bool forceFsync) { strerror(errno)); } } + taosThreadMutexUnlock(&pWal->mutex); }