From 336ee146e618d4f81c42c3b4eba128ca66113d0d Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Thu, 22 Dec 2022 17:56:56 +0800 Subject: [PATCH] fix(tdb/restore): seek jfd to begin --- source/libs/tdb/src/db/tdbPager.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 8d9933b160..2a2a6f8bbd 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -869,6 +869,12 @@ static int tdbPagerRestore(SPager *pPager, const char *jFileName) { return -1; } + if (tdbOsLSeek(jfd, 0L, SEEK_SET) < 0) { + tdbError("failed to lseek jfd due to %s. file:%s, offset:0", strerror(errno), pPager->dbFileName); + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } + pageBuf = tdbOsCalloc(1, pPager->pageSize); if (pageBuf == NULL) { return -1;