From cda8ebe0bdc8517385c94f8d969a0a9fe1079d32 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, 22 Jul 2024 12:48:43 +0300 Subject: [PATCH] =?UTF-8?q?mdbx:=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D0=BA=D0=B0=20=D1=81=D0=BE=D0=B2=D0=BC=D0=B5=D1=81=D1=82=D0=BC?= =?UTF-8?q?=D0=BE=D1=81=D1=82=D0=B8=20=D1=84=D0=BB=D0=B0=D0=B3=D0=BE=D0=B2?= =?UTF-8?q?=20GC/FreeDB=20(backport).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/core.c b/src/core.c index cd382ada..727fdf6d 100644 --- a/src/core.c +++ b/src/core.c @@ -9164,9 +9164,10 @@ static int txn_renew(MDBX_txn *txn, const unsigned flags) { } #endif /* Windows */ } else { - if (unlikely(txn->mt_dbs[FREE_DBI].md_flags != MDBX_INTEGERKEY)) { - ERROR("unexpected/invalid db-flags 0x%u for GC/FreeDB", - txn->mt_dbs[FREE_DBI].md_flags); + if (unlikely((txn->mt_dbs[FREE_DBI].md_flags & DB_PERSISTENT_FLAGS) != + MDBX_INTEGERKEY)) { + ERROR("unexpected/invalid db-flags 0x%x for %s", + txn->mt_dbs[FREE_DBI].md_flags, "GC/FreeDB"); rc = MDBX_INCOMPATIBLE; goto bailout; } @@ -12424,12 +12425,12 @@ static int validate_meta(MDBX_env *env, MDBX_meta *const meta, meta->mm_dbs[FREE_DBI].md_entries || meta->mm_dbs[FREE_DBI].md_leaf_pages || meta->mm_dbs[FREE_DBI].md_overflow_pages)) { - WARNING("meta[%u] has false-empty %s, skip it", meta_number, "GC"); + WARNING("meta[%u] has false-empty %s, skip it", meta_number, "GC/FreeDB"); return MDBX_CORRUPTED; } } else if (unlikely(meta->mm_dbs[FREE_DBI].md_root >= meta->mm_geo.next)) { WARNING("meta[%u] has invalid %s-root %" PRIaPGNO ", skip it", meta_number, - "GC", meta->mm_dbs[FREE_DBI].md_root); + "GC/FreeDB", meta->mm_dbs[FREE_DBI].md_root); return MDBX_CORRUPTED; } @@ -12451,7 +12452,7 @@ static int validate_meta(MDBX_env *env, MDBX_meta *const meta, if (unlikely(meta->mm_dbs[FREE_DBI].md_mod_txnid > txnid)) { WARNING("meta[%u] has wrong md_mod_txnid %" PRIaTXN " for %s, skip it", - meta_number, meta->mm_dbs[FREE_DBI].md_mod_txnid, "GC"); + meta_number, meta->mm_dbs[FREE_DBI].md_mod_txnid, "GC/FreeDB"); return MDBX_CORRUPTED; } @@ -12461,6 +12462,13 @@ static int validate_meta(MDBX_env *env, MDBX_meta *const meta, return MDBX_CORRUPTED; } + if (unlikely((meta->mm_dbs[FREE_DBI].md_flags & DB_PERSISTENT_FLAGS) != + MDBX_INTEGERKEY)) { + WARNING("meta[%u] has unexpected/invalid db-flags 0x%x for %s", meta_number, + meta->mm_dbs[FREE_DBI].md_flags, "GC/FreeDB"); + return MDBX_INCOMPATIBLE; + } + return MDBX_SUCCESS; }