Skip to content

Commit

Permalink
Merge pull request #22772 from taosdata/fix/TD-25996-main
Browse files Browse the repository at this point in the history
fix/TD-25996: tdbBtcDelete release pages before modifying pBtc->pPage
  • Loading branch information
gccgdb1234 committed Sep 6, 2023
2 parents e493f98 + 7257518 commit 42d63be
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions source/libs/tdb/src/db/tdbBtree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2200,10 +2200,15 @@ int tdbBtcDelete(SBTC *pBtc) {
tdbOsFree(pCell);

if (pPage->nOverflow > 0) {
tdbDebug("tdb/btc-delete: btree balance after update cell, pPage/nOverflow: %p/%d.", pPage,
pPage->nOverflow);
tdbDebug("tdb/btc-delete: btree balance after update cell, pPage/nOverflow/pgno: %p/%d/%" PRIu32 ".", pPage,
pPage->nOverflow, TDB_PAGE_PGNO(pPage));

pBtc->iPage = iPage;
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage, pBtc->pTxn);
while (--pBtc->iPage != iPage) {
tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pgStack[pBtc->iPage], pBtc->pTxn);
}

// pBtc->iPage = iPage;
pBtc->pPage = pPage;
ret = tdbBtreeBalance(pBtc);
if (ret < 0) {
Expand Down
2 changes: 1 addition & 1 deletion source/libs/tdb/src/db/tdbPCache.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, TXN *pTxn)
}

// 1. pPage == NULL
// 2. pPage && pPage->isLocal == 0 && !TDB_TXN_IS_WRITE(pTxn)
// 2. pPage && !pPage->isLocal == 0 && !TDB_TXN_IS_WRITE(pTxn)
pPageH = pPage;
pPage = NULL;

Expand Down

0 comments on commit 42d63be

Please sign in to comment.