mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 01:14:13 +08:00
mdbx: доработка mdbx_env_turn_for_recovery()
чтобы не обновлять мета-страницы при отсутствии изменений.
This commit is contained in:
parent
d516e903d4
commit
db6cf469c9
20
src/core.c
20
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user