Merge pull request #19469 from taosdata/FIX/TD-21851-main

fix: synchronize access within walFsync
This commit is contained in:
Shengliang Guan 2023-01-10 15:19:13 +08:00 committed by GitHub
commit 2a087a9be8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 0 deletions

View File

@ -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);
}