mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 18:34:13 +08:00
mdbx-chk: directly use mdbx_txn_lock() for write/recovery mode.
This commit is contained in:
parent
8d748a845b
commit
dd6cb30820
@ -763,6 +763,7 @@ int main(int argc, char *argv[]) {
|
|||||||
char *envname;
|
char *envname;
|
||||||
int problems_maindb = 0, problems_freedb = 0, problems_meta = 0;
|
int problems_maindb = 0, problems_freedb = 0, problems_meta = 0;
|
||||||
int dont_traversal = 0;
|
int dont_traversal = 0;
|
||||||
|
bool locked = false;
|
||||||
|
|
||||||
double elapsed;
|
double elapsed;
|
||||||
#if defined(_WIN32) || defined(_WIN64)
|
#if defined(_WIN32) || defined(_WIN64)
|
||||||
@ -862,10 +863,18 @@ int main(int argc, char *argv[]) {
|
|||||||
if (verbose)
|
if (verbose)
|
||||||
print(" - %s mode\n", exclusive ? "monopolistic" : "cooperative");
|
print(" - %s mode\n", exclusive ? "monopolistic" : "cooperative");
|
||||||
|
|
||||||
rc = mdbx_txn_begin(env, NULL, envflags & MDBX_RDONLY, &txn);
|
if ((envflags & MDBX_RDONLY) == 0) {
|
||||||
|
rc = mdbx_txn_lock(env, false);
|
||||||
|
if (rc != MDBX_SUCCESS) {
|
||||||
|
error("mdbx_txn_lock failed, error %d %s\n", rc, mdbx_strerror(rc));
|
||||||
|
goto bailout;
|
||||||
|
}
|
||||||
|
locked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
rc = mdbx_txn_begin(env, NULL, MDBX_RDONLY, &txn);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
error("mdbx_txn_begin(read-%s) failed, error %d %s\n",
|
error("mdbx_txn_begin() failed, error %d %s\n", rc, mdbx_strerror(rc));
|
||||||
(envflags & MDBX_RDONLY) ? "only" : "write", rc, mdbx_strerror(rc));
|
|
||||||
goto bailout;
|
goto bailout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -941,14 +950,14 @@ int main(int argc, char *argv[]) {
|
|||||||
if (verbose)
|
if (verbose)
|
||||||
print(" - performs full check recent-txn-id with meta-pages\n");
|
print(" - performs full check recent-txn-id with meta-pages\n");
|
||||||
problems_meta += check_meta_head(true);
|
problems_meta += check_meta_head(true);
|
||||||
} else if (mdbx_txn_flags(txn) & MDBX_RDONLY) {
|
} else if (locked) {
|
||||||
print(" - skip check recent-txn-id with meta-pages (monopolistic or "
|
|
||||||
"read-write mode only)\n");
|
|
||||||
} else if (verbose) {
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
print(" - performs lite check recent-txn-id with meta-pages (not a "
|
print(" - performs lite check recent-txn-id with meta-pages (not a "
|
||||||
"monopolistic mode)\n");
|
"monopolistic mode)\n");
|
||||||
problems_meta += check_meta_head(false);
|
problems_meta += check_meta_head(false);
|
||||||
|
} else if (verbose) {
|
||||||
|
print(" - skip check recent-txn-id with meta-pages (monopolistic or "
|
||||||
|
"read-write mode only)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dont_traversal) {
|
if (!dont_traversal) {
|
||||||
@ -1093,6 +1102,8 @@ int main(int argc, char *argv[]) {
|
|||||||
bailout:
|
bailout:
|
||||||
if (txn)
|
if (txn)
|
||||||
mdbx_txn_abort(txn);
|
mdbx_txn_abort(txn);
|
||||||
|
if (locked)
|
||||||
|
mdbx_txn_unlock(env);
|
||||||
if (env)
|
if (env)
|
||||||
mdbx_env_close(env);
|
mdbx_env_close(env);
|
||||||
fflush(NULL);
|
fflush(NULL);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user