mdbx: доработка mdbx_env_turn_for_recovery() чтобы не обновлять мета-страницы при отсутствии изменений.

This commit is contained in:
Леонид Юрьев (Leonid Yuriev) 2023-06-08 01:15:02 +03:00
parent d516e903d4
commit db6cf469c9

View File

@ -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;