enh: write idx ahead of writing its log entry in WAL
This commit is contained in:
parent
af9aa9d783
commit
cf2b6ccbfb
|
@ -449,6 +449,11 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
|||
pWal->writeHead.cksumBody = walCalcBodyCksum(body, bodyLen);
|
||||
wDebug("vgId:%d, wal write log %ld, msgType: %s", pWal->cfg.vgId, index, TMSG_INFO(msgType));
|
||||
|
||||
code = walWriteIndex(pWal, index, offset);
|
||||
if (code < 0) {
|
||||
goto END;
|
||||
}
|
||||
|
||||
if (taosWriteFile(pWal->pLogFile, &pWal->writeHead, sizeof(SWalCkHead)) != sizeof(SWalCkHead)) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
wError("vgId:%d, file:%" PRId64 ".log, failed to write since %s", pWal->cfg.vgId, walGetLastFileFirstVer(pWal),
|
||||
|
@ -465,11 +470,6 @@ static FORCE_INLINE int32_t walWriteImpl(SWal *pWal, int64_t index, tmsg_t msgTy
|
|||
goto END;
|
||||
}
|
||||
|
||||
code = walWriteIndex(pWal, index, offset);
|
||||
if (code < 0) {
|
||||
goto END;
|
||||
}
|
||||
|
||||
// set status
|
||||
if (pWal->vers.firstVer == -1) pWal->vers.firstVer = index;
|
||||
pWal->vers.lastVer = index;
|
||||
|
|
Loading…
Reference in New Issue