mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 01:04:13 +08:00
mdbx: проверка номеров корневых страниц в coherency_check()
(backport).
This commit is contained in:
parent
7eb2f4130e
commit
ab5d290f11
29
src/core.c
29
src/core.c
@ -8615,20 +8615,45 @@ static bool coherency_check(const MDBX_env *env, const txnid_t txnid,
|
|||||||
const volatile MDBX_meta *meta, bool report) {
|
const volatile MDBX_meta *meta, bool report) {
|
||||||
const txnid_t freedb_mod_txnid = dbs[FREE_DBI].md_mod_txnid;
|
const txnid_t freedb_mod_txnid = dbs[FREE_DBI].md_mod_txnid;
|
||||||
const txnid_t maindb_mod_txnid = dbs[MAIN_DBI].md_mod_txnid;
|
const txnid_t maindb_mod_txnid = dbs[MAIN_DBI].md_mod_txnid;
|
||||||
|
const pgno_t last_pgno = meta->mm_geo.now;
|
||||||
|
|
||||||
const pgno_t freedb_root_pgno = dbs[FREE_DBI].md_root;
|
const pgno_t freedb_root_pgno = dbs[FREE_DBI].md_root;
|
||||||
const MDBX_page *freedb_root = (env->me_map && freedb_root_pgno != P_INVALID)
|
const MDBX_page *freedb_root = (env->me_map && freedb_root_pgno < last_pgno)
|
||||||
? pgno2page(env, freedb_root_pgno)
|
? pgno2page(env, freedb_root_pgno)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
|
|
||||||
const pgno_t maindb_root_pgno = dbs[MAIN_DBI].md_root;
|
const pgno_t maindb_root_pgno = dbs[MAIN_DBI].md_root;
|
||||||
const MDBX_page *maindb_root = (env->me_map && maindb_root_pgno != P_INVALID)
|
const MDBX_page *maindb_root = (env->me_map && maindb_root_pgno < last_pgno)
|
||||||
? pgno2page(env, maindb_root_pgno)
|
? pgno2page(env, maindb_root_pgno)
|
||||||
: nullptr;
|
: nullptr;
|
||||||
const uint64_t magic_and_version =
|
const uint64_t magic_and_version =
|
||||||
unaligned_peek_u64_volatile(4, &meta->mm_magic_and_version);
|
unaligned_peek_u64_volatile(4, &meta->mm_magic_and_version);
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
|
if (freedb_root_pgno != P_INVALID &&
|
||||||
|
unlikely(freedb_root_pgno >= last_pgno)) {
|
||||||
|
if (report)
|
||||||
|
WARNING(
|
||||||
|
"catch invalid %sdb root %" PRIaPGNO " for meta_txnid %" PRIaTXN
|
||||||
|
" %s",
|
||||||
|
"free", freedb_root_pgno, txnid,
|
||||||
|
(env->me_stuck_meta < 0)
|
||||||
|
? "(workaround for incoherent flaw of unified page/buffer cache)"
|
||||||
|
: "(wagering meta)");
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
if (maindb_root_pgno != P_INVALID &&
|
||||||
|
unlikely(maindb_root_pgno >= last_pgno)) {
|
||||||
|
if (report)
|
||||||
|
WARNING(
|
||||||
|
"catch invalid %sdb root %" PRIaPGNO " for meta_txnid %" PRIaTXN
|
||||||
|
" %s",
|
||||||
|
"main", maindb_root_pgno, txnid,
|
||||||
|
(env->me_stuck_meta < 0)
|
||||||
|
? "(workaround for incoherent flaw of unified page/buffer cache)"
|
||||||
|
: "(wagering meta)");
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
if (unlikely(txnid < freedb_mod_txnid ||
|
if (unlikely(txnid < freedb_mod_txnid ||
|
||||||
(!freedb_mod_txnid && freedb_root &&
|
(!freedb_mod_txnid && freedb_root &&
|
||||||
likely(magic_and_version == MDBX_DATA_MAGIC)))) {
|
likely(magic_and_version == MDBX_DATA_MAGIC)))) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user