From d5f140aee2177b762901436bc421698c3381daef Mon Sep 17 00:00:00 2001 From: Minglei Jin Date: Mon, 29 Apr 2024 15:23:00 +0800 Subject: [PATCH] fix(tdb/btc): free txn early when closing btc --- source/libs/tdb/src/db/tdbBtree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index 7a62b38b16..543e06aae6 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -2473,6 +2473,10 @@ int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { } int tdbBtcClose(SBTC *pBtc) { + if (pBtc->freeTxn) { + tdbTxnClose(pBtc->pTxn); + } + if (pBtc->iPage < 0) return 0; for (;;) { @@ -2496,10 +2500,6 @@ int tdbBtcClose(SBTC *pBtc) { tdbFree(pBtc->coder.pVal); } - if (pBtc->freeTxn) { - tdbTxnClose(pBtc->pTxn); - } - return 0; }