From a89d418c9139f92967fdb2c96a2d79e848706f09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Mon, 6 Jan 2025 23:34:14 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D1=80=D0=B5=D1=84=D0=B0=D0=BA=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=B8=D0=BD=D0=B3=20`mdbx=5Ftxn=5Fstraggler()`=20?= =?UTF-8?q?=D1=81=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=D0=BC=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8?= =?UTF-8?q?=20`env`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api-txn.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/api-txn.c b/src/api-txn.c index 4a36ea56..e4e80cb0 100644 --- a/src/api-txn.c +++ b/src/api-txn.c @@ -10,10 +10,11 @@ __attribute__((__no_sanitize_thread__, __noinline__)) int mdbx_txn_straggler(const MDBX_txn *txn, int *percent) { int rc = check_txn(txn, MDBX_TXN_BLOCKED); + if (likely(rc == MDBX_SUCCESS)) + rc = check_env(txn->env, true); if (unlikely(rc != MDBX_SUCCESS)) return LOG_IFERR((rc > 0) ? -rc : rc); - MDBX_env *env = txn->env; if (unlikely((txn->flags & MDBX_TXN_RDONLY) == 0)) { if (percent) *percent = (int)((txn->geo.first_unallocated * UINT64_C(100) + txn->geo.end_pgno / 2) / txn->geo.end_pgno); @@ -21,15 +22,15 @@ int mdbx_txn_straggler(const MDBX_txn *txn, int *percent) } txnid_t lag; - troika_t troika = meta_tap(env); + troika_t troika = meta_tap(txn->env); do { - const meta_ptr_t head = meta_recent(env, &troika); + const meta_ptr_t head = meta_recent(txn->env, &troika); if (percent) { const pgno_t maxpg = head.ptr_v->geometry.now; *percent = (int)((head.ptr_v->geometry.first_unallocated * UINT64_C(100) + maxpg / 2) / maxpg); } lag = (head.txnid - txn->txnid) / xMDBX_TXNID_STEP; - } while (unlikely(meta_should_retry(env, &troika))); + } while (unlikely(meta_should_retry(txn->env, &troika))); return (lag > INT_MAX) ? INT_MAX : (int)lag; }