From ca23365d6887f33fc9e6e706194edfe046a80d98 Mon Sep 17 00:00:00 2001 From: Benguang Zhao Date: Thu, 2 Mar 2023 20:40:34 +0800 Subject: [PATCH] enh: fsync WAL idx and log when walRollImpl --- source/libs/wal/src/walWrite.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/source/libs/wal/src/walWrite.c b/source/libs/wal/src/walWrite.c index a992c951fa..b74bbdd15f 100644 --- a/source/libs/wal/src/walWrite.c +++ b/source/libs/wal/src/walWrite.c @@ -387,20 +387,33 @@ END: int32_t walRollImpl(SWal *pWal) { int32_t code = 0; + if (pWal->pIdxFile != NULL) { + code = taosFsyncFile(pWal->pIdxFile); + if (code != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto END; + } code = taosCloseFile(&pWal->pIdxFile); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(errno); goto END; } } + if (pWal->pLogFile != NULL) { + code = taosFsyncFile(pWal->pLogFile); + if (code != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + goto END; + } code = taosCloseFile(&pWal->pLogFile); if (code != 0) { terrno = TAOS_SYSTEM_ERROR(errno); goto END; } } + TdFilePtr pIdxFile, pLogFile; // create new file int64_t newFileFirstVer = pWal->vers.lastVer + 1;