mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-20 05:28:21 +08:00
mdbx: refine override_meta()
to preserve format-signature for legacy/zero mod_txnid.
This commit is contained in:
parent
de63041b7d
commit
b79f6712e3
28
src/core.c
28
src/core.c
@ -12618,9 +12618,13 @@ __cold static int __must_check_result mdbx_override_meta(
|
|||||||
meta_set_txnid(env, model, txnid);
|
meta_set_txnid(env, model, txnid);
|
||||||
mdbx_assert(env, meta_checktxnid(env, model, true));
|
mdbx_assert(env, meta_checktxnid(env, model, true));
|
||||||
if (shape) {
|
if (shape) {
|
||||||
mdbx_assert(env, meta_checktxnid(env, shape, true));
|
if (txnid && unlikely(!meta_checktxnid(env, shape, false))) {
|
||||||
if (env->me_stuck_meta >= 0 ||
|
mdbx_error("bailout overriding meta-%u since model failed "
|
||||||
(mdbx_runtime_flags & MDBX_DBG_DONT_UPGRADE) != 0)
|
"freedb/maindb %s-check for txnid #%" PRIaTXN,
|
||||||
|
target, "pre", constmeta_txnid(env, shape));
|
||||||
|
return MDBX_PROBLEM;
|
||||||
|
}
|
||||||
|
if (mdbx_runtime_flags & MDBX_DBG_DONT_UPGRADE)
|
||||||
memcpy(&model->mm_magic_and_version, &shape->mm_magic_and_version,
|
memcpy(&model->mm_magic_and_version, &shape->mm_magic_and_version,
|
||||||
sizeof(model->mm_magic_and_version));
|
sizeof(model->mm_magic_and_version));
|
||||||
model->mm_extra_flags = shape->mm_extra_flags;
|
model->mm_extra_flags = shape->mm_extra_flags;
|
||||||
@ -12631,13 +12635,29 @@ __cold static int __must_check_result mdbx_override_meta(
|
|||||||
memcpy(&model->mm_canary, &shape->mm_canary, sizeof(model->mm_canary));
|
memcpy(&model->mm_canary, &shape->mm_canary, sizeof(model->mm_canary));
|
||||||
memcpy(&model->mm_pages_retired, &shape->mm_pages_retired,
|
memcpy(&model->mm_pages_retired, &shape->mm_pages_retired,
|
||||||
sizeof(model->mm_pages_retired));
|
sizeof(model->mm_pages_retired));
|
||||||
mdbx_assert(env, meta_checktxnid(env, model, true));
|
if (txnid) {
|
||||||
|
if ((!model->mm_dbs[FREE_DBI].md_mod_txnid &&
|
||||||
|
model->mm_dbs[FREE_DBI].md_root != P_INVALID) ||
|
||||||
|
(!model->mm_dbs[MAIN_DBI].md_mod_txnid &&
|
||||||
|
model->mm_dbs[MAIN_DBI].md_root != P_INVALID))
|
||||||
|
memcpy(&model->mm_magic_and_version, &shape->mm_magic_and_version,
|
||||||
|
sizeof(model->mm_magic_and_version));
|
||||||
|
if (unlikely(!meta_checktxnid(env, model, false))) {
|
||||||
|
mdbx_error("bailout overriding meta-%u since model failed "
|
||||||
|
"freedb/maindb %s-check for txnid #%" PRIaTXN,
|
||||||
|
target, "post", txnid);
|
||||||
|
return MDBX_PROBLEM;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
unaligned_poke_u64(4, model->mm_datasync_sign, meta_sign(model));
|
unaligned_poke_u64(4, model->mm_datasync_sign, meta_sign(model));
|
||||||
rc = mdbx_validate_meta(env, model, page, target, nullptr);
|
rc = mdbx_validate_meta(env, model, page, target, nullptr);
|
||||||
if (unlikely(MDBX_IS_ERROR(rc)))
|
if (unlikely(MDBX_IS_ERROR(rc)))
|
||||||
return MDBX_PROBLEM;
|
return MDBX_PROBLEM;
|
||||||
|
|
||||||
|
if (shape && memcmp(model, shape, sizeof(MDBX_meta)) == 0)
|
||||||
|
return MDBX_SUCCESS;
|
||||||
|
|
||||||
#if MDBX_ENABLE_PGOP_STAT
|
#if MDBX_ENABLE_PGOP_STAT
|
||||||
env->me_lck->mti_pgop_stat.wops.weak += 1;
|
env->me_lck->mti_pgop_stat.wops.weak += 1;
|
||||||
#endif /* MDBX_ENABLE_PGOP_STAT */
|
#endif /* MDBX_ENABLE_PGOP_STAT */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user