Merge pull request #20252 from taosdata/FIX/TD-22944-main

enh: fsync WAL idx and log when walRollImpl
This commit is contained in:
Xiaoyu Wang 2023-03-03 15:12:53 +08:00 committed by GitHub
commit fb81b4abeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 13 additions and 0 deletions

View File

@ -387,20 +387,33 @@ END:
int32_t walRollImpl(SWal *pWal) { int32_t walRollImpl(SWal *pWal) {
int32_t code = 0; int32_t code = 0;
if (pWal->pIdxFile != NULL) { if (pWal->pIdxFile != NULL) {
code = taosFsyncFile(pWal->pIdxFile);
if (code != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
goto END;
}
code = taosCloseFile(&pWal->pIdxFile); code = taosCloseFile(&pWal->pIdxFile);
if (code != 0) { if (code != 0) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
goto END; goto END;
} }
} }
if (pWal->pLogFile != NULL) { if (pWal->pLogFile != NULL) {
code = taosFsyncFile(pWal->pLogFile);
if (code != 0) {
terrno = TAOS_SYSTEM_ERROR(errno);
goto END;
}
code = taosCloseFile(&pWal->pLogFile); code = taosCloseFile(&pWal->pLogFile);
if (code != 0) { if (code != 0) {
terrno = TAOS_SYSTEM_ERROR(errno); terrno = TAOS_SYSTEM_ERROR(errno);
goto END; goto END;
} }
} }
TdFilePtr pIdxFile, pLogFile; TdFilePtr pIdxFile, pLogFile;
// create new file // create new file
int64_t newFileFirstVer = pWal->vers.lastVer + 1; int64_t newFileFirstVer = pWal->vers.lastVer + 1;