From 319753661a2c76be40adbed5fc06d61bb3b28078 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: Fri, 5 Jul 2024 22:00:05 +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`coherency=5Fcheck=5Fwritten()?= =?UTF-8?q?`.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/coherency.c | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/coherency.c b/src/coherency.c index 4bab049f..5e491b1b 100644 --- a/src/coherency.c +++ b/src/coherency.c @@ -168,26 +168,24 @@ int coherency_check_written(const MDBX_env *env, const txnid_t txnid, uint64_t *timestamp) { const bool report = !(timestamp && *timestamp); const txnid_t head_txnid = meta_txnid(meta); - if (unlikely(head_txnid < MIN_TXNID || head_txnid < txnid)) { - if (report) { - env->lck->pgops.incoherence.weak = - (env->lck->pgops.incoherence.weak >= INT32_MAX) - ? INT32_MAX - : env->lck->pgops.incoherence.weak + 1; - WARNING("catch %s txnid %" PRIaTXN " for meta_%" PRIaPGNO " %s", - (head_txnid < MIN_TXNID) ? "invalid" : "unexpected", head_txnid, - bytes2pgno(env, ptr_dist(meta, env->dxb_mmap.base)), - "(workaround for incoherent flaw of unified page/buffer cache)"); + if (likely(head_txnid >= MIN_TXNID && head_txnid >= txnid)) { + if (likely( + coherency_check(env, head_txnid, &meta->trees.gc, meta, report))) { + eASSERT(env, meta->trees.gc.flags == MDBX_INTEGERKEY); + eASSERT(env, check_sdb_flags(meta->trees.main.flags)); + return MDBX_SUCCESS; } - return coherency_timeout(timestamp, pgno, env); + } else if (report) { + env->lck->pgops.incoherence.weak = + (env->lck->pgops.incoherence.weak >= INT32_MAX) + ? INT32_MAX + : env->lck->pgops.incoherence.weak + 1; + WARNING("catch %s txnid %" PRIaTXN " for meta_%" PRIaPGNO " %s", + (head_txnid < MIN_TXNID) ? "invalid" : "unexpected", head_txnid, + bytes2pgno(env, ptr_dist(meta, env->dxb_mmap.base)), + "(workaround for incoherent flaw of unified page/buffer cache)"); } - if (unlikely( - !coherency_check(env, head_txnid, &meta->trees.gc, meta, report))) - return coherency_timeout(timestamp, pgno, env); - - eASSERT(env, meta->trees.gc.flags == MDBX_INTEGERKEY); - eASSERT(env, check_sdb_flags(meta->trees.main.flags)); - return MDBX_SUCCESS; + return coherency_timeout(timestamp, pgno, env); } bool coherency_check_meta(const MDBX_env *env, const volatile meta_t *meta,