fix: deal with misaligned idx entries in walCheckAndRepairIdxFile
This commit is contained in:
parent
23a4a37677
commit
3190ef65a3
|
@ -481,6 +481,10 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (offset != (idxEntry.ver - pFileInfo->firstVer) * sizeof(SWalIdxEntry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (walReadLogHead(pLogFile, idxEntry.offset, &ckHead) < 0) {
|
if (walReadLogHead(pLogFile, idxEntry.offset, &ckHead) < 0) {
|
||||||
wWarn("vgId:%d, failed to read log file since %s. file:%s, offset:%" PRId64 ", idx entry ver:%" PRId64 "",
|
wWarn("vgId:%d, failed to read log file since %s. file:%s, offset:%" PRId64 ", idx entry ver:%" PRId64 "",
|
||||||
pWal->cfg.vgId, terrstr(), fLogNameStr, idxEntry.offset, idxEntry.ver);
|
pWal->cfg.vgId, terrstr(), fLogNameStr, idxEntry.offset, idxEntry.ver);
|
||||||
|
@ -493,6 +497,8 @@ int walCheckAndRepairIdxFile(SWal* pWal, int32_t fileIdx) {
|
||||||
}
|
}
|
||||||
offset += sizeof(SWalIdxEntry);
|
offset += sizeof(SWalIdxEntry);
|
||||||
|
|
||||||
|
ASSERT(offset == (idxEntry.ver - pFileInfo->firstVer + 1) * sizeof(SWalIdxEntry));
|
||||||
|
|
||||||
// ftruncate idx file
|
// ftruncate idx file
|
||||||
if (offset < fileSize) {
|
if (offset < fileSize) {
|
||||||
if (taosFtruncateFile(pIdxFile, offset) < 0) {
|
if (taosFtruncateFile(pIdxFile, offset) < 0) {
|
||||||
|
|
Loading…
Reference in New Issue