From db6cf469c979e962cdffa09095c0a43c70bf3dcd 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: Thu, 8 Jun 2023 01:15:02 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=B4=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20`mdbx=5Fenv=5Fturn=5Ffor=5Frecovery()`=20?= =?UTF-8?q?=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20=D0=BD=D0=B5=20=D0=BE=D0=B1?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BB=D1=8F=D1=82=D1=8C=20=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=B0-=D1=81=D1=82=D1=80=D0=B0=D0=BD=D0=B8=D1=86=D1=8B=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D0=BE=D1=82=D1=81=D1=83=D1=82=D1=81=D1=82?= =?UTF-8?q?=D0=B2=D0=B8=D0=B8=20=D0=B8=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/core.c b/src/core.c index 9b3cb61a..1b52e233 100644 --- a/src/core.c +++ b/src/core.c @@ -14383,8 +14383,12 @@ __cold static int __must_check_result override_meta(MDBX_env *env, if (unlikely(MDBX_IS_ERROR(rc))) return MDBX_PROBLEM; - if (shape && memcmp(model, shape, sizeof(MDBX_meta)) == 0) + if (shape && memcmp(model, shape, sizeof(MDBX_meta)) == 0) { + NOTICE("skip overriding meta-%zu since no changes " + "for txnid #%" PRIaTXN, + target, txnid); return MDBX_SUCCESS; + } if (env->me_flags & MDBX_WRITEMAP) { #if MDBX_ENABLE_PGOP_STAT @@ -14438,14 +14442,16 @@ __cold int mdbx_env_turn_for_recovery(MDBX_env *env, unsigned target) { MDBX_EXCLUSIVE)) return MDBX_EPERM; - const MDBX_meta *target_meta = METAPAGE(env, target); - txnid_t new_txnid = safe64_txnid_next(constmeta_txnid(target_meta)); - for (size_t n = 0; n < NUM_METAS; ++n) { + const MDBX_meta *const target_meta = METAPAGE(env, target); + txnid_t new_txnid = constmeta_txnid(target_meta); + if (new_txnid < MIN_TXNID) + new_txnid = MIN_TXNID; + for (unsigned n = 0; n < NUM_METAS; ++n) { if (n == target) continue; - MDBX_meta meta = *METAPAGE(env, n); - if (validate_meta(env, &meta, pgno2page(env, n), (pgno_t)n, nullptr) != - MDBX_SUCCESS) { + MDBX_page *const page = pgno2page(env, n); + MDBX_meta meta = *page_meta(page); + if (validate_meta(env, &meta, page, n, nullptr) != MDBX_SUCCESS) { int err = override_meta(env, n, 0, nullptr); if (unlikely(err != MDBX_SUCCESS)) return err;