From 73e91f649196e86c4e0c3b1c155a9d735594f97b Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Sun, 17 Jul 2022 14:27:13 +0800 Subject: [PATCH] fix wal kill case --- source/libs/tdb/src/db/tdbBtree.c | 3 ++- source/libs/tdb/src/db/tdbPager.c | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 8d7a2e1be6..cca451ceb7 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -132,7 +132,8 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, char const *tbname, SPg } } - tdbUnrefPage(pPage); + // tdbUnrefPage(pPage); + tdbPCacheRelease(pPager->pCache, pPage, &txn); tdbCommit(pPager->pEnv, &txn); tdbTxnClose(&txn); } diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 516804cad9..e7765ed667 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -474,7 +474,7 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) { } TXN txn; - tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, 0); + tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED); SBtreeInitPageArg iArg; iArg.pBt = pBt; iArg.flags = 0; @@ -494,6 +494,7 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) { return -1; } + /* ret = tdbPagerFetchPage(pPager, &pgno, &pPage, tdbBtreeInitPage, &iArg, &txn); if (ret < 0) { return -1; @@ -506,6 +507,18 @@ int tdbPagerRestore(SPager *pPager, SBTree *pBt) { } tdbPCacheRelease(pPager->pCache, pPage, &txn); + */ + i64 offset = pPager->pageSize * (pgno - 1); + if (tdbOsLSeek(pPager->fd, offset, SEEK_SET) < 0) { + ASSERT(0); + return -1; + } + + ret = tdbOsWrite(pPager->fd, pageBuf, pPager->pageSize); + if (ret < 0) { + ASSERT(0); + return -1; + } } tdbOsFSync(pPager->fd); -- GitLab