mdbx: don't check other meta pages if one is specified for verification/recovery.

Fixes https://github.com/erthink/libmdbx/issues/202
This commit is contained in:
Leonid Yuriev 2021-06-08 20:27:18 +03:00
parent 0e83a8e5ef
commit 0cd1eac6a8
2 changed files with 73 additions and 60 deletions

View File

@ -11583,6 +11583,7 @@ static __cold int mdbx_setup_dxb(MDBX_env *env, const int lck_rc) {
env->me_poison_edge = bytes2pgno(env, env->me_dxb_mmap.limit);
#endif /* MDBX_USE_VALGRIND || __SANITIZE_ADDRESS__ */
while (likely(/* not recovery mode */ env->me_stuck_meta < 0)) {
const unsigned meta_clash_mask = mdbx_meta_eq_mask(env);
if (unlikely(meta_clash_mask)) {
if (/* not recovery mode */ env->me_stuck_meta < 0) {
@ -11594,7 +11595,6 @@ static __cold int mdbx_setup_dxb(MDBX_env *env, const int lck_rc) {
}
}
while (likely(/* not recovery mode */ env->me_stuck_meta < 0)) {
MDBX_meta *const head = mdbx_meta_head(env);
const txnid_t head_txnid = mdbx_meta_txnid_fluid(env, head);
MDBX_meta *const steady = mdbx_meta_steady(env);

View File

@ -1376,11 +1376,6 @@ int main(int argc, char *argv[]) {
"of may by large than the database itself,\n "
"until it will be closed or reopened in read-write mode.\n");
#endif
print(" - transactions: recent %" PRIu64 ", latter reader %" PRIu64
", lag %" PRIi64 "\n",
envinfo.mi_recent_txnid, envinfo.mi_latter_reader_txnid,
envinfo.mi_recent_txnid - envinfo.mi_latter_reader_txnid);
verbose_meta(0, envinfo.mi_meta0_txnid, envinfo.mi_meta0_sign,
envinfo.mi_bootid.meta0.x, envinfo.mi_bootid.meta0.y);
verbose_meta(1, envinfo.mi_meta1_txnid, envinfo.mi_meta1_sign,
@ -1389,6 +1384,17 @@ int main(int argc, char *argv[]) {
envinfo.mi_bootid.meta2.x, envinfo.mi_bootid.meta2.y);
}
if (stuck_meta >= 0) {
if (verbose) {
print(" - skip checking meta-pages since the %u"
" is selected for verification\n",
stuck_meta);
print(" - transactions: recent %" PRIu64
", selected for verification %" PRIu64 ", lag %" PRIi64 "\n",
envinfo.mi_recent_txnid, get_meta_txnid(stuck_meta),
envinfo.mi_recent_txnid - get_meta_txnid(stuck_meta));
}
} else {
if (verbose > 1)
print(" - performs check for meta-pages clashes\n");
if (meta_eq(envinfo.mi_meta0_txnid, envinfo.mi_meta0_sign,
@ -1436,6 +1442,13 @@ int main(int argc, char *argv[]) {
}
total_problems += problems_meta;
if (verbose)
print(" - transactions: recent %" PRIu64 ", latter reader %" PRIu64
", lag %" PRIi64 "\n",
envinfo.mi_recent_txnid, envinfo.mi_latter_reader_txnid,
envinfo.mi_recent_txnid - envinfo.mi_latter_reader_txnid);
}
if (!dont_traversal) {
struct problem *saved_list;
size_t traversal_problems;
@ -1603,7 +1616,7 @@ int main(int argc, char *argv[]) {
if (rc == 0 && total_problems == 1 && problems_meta == 1 && !dont_traversal &&
(envflags & MDBX_RDONLY) == 0 && !only_subdb && stuck_meta < 0 &&
steady_meta_txnid < envinfo.mi_recent_txnid) {
get_meta_txnid(meta_recent(true)) < envinfo.mi_recent_txnid) {
print("Perform sync-to-disk for make steady checkpoint at txn-id #%" PRIi64
"\n",
envinfo.mi_recent_txnid);