mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 00:44:12 +08:00
mdbx: minor fix meta_checktxnid()
to avoid assertion in debug mode.
This commit is contained in:
parent
f17bd06116
commit
6e2a1ebfbd
@ -18,6 +18,7 @@ Minors:
|
|||||||
|
|
||||||
- Minor fixes Doxygen references, comments, descriptions, etc.
|
- Minor fixes Doxygen references, comments, descriptions, etc.
|
||||||
- Fixed copy&paste typo inside `meta_checktxnid()`.
|
- Fixed copy&paste typo inside `meta_checktxnid()`.
|
||||||
|
- Minor fix `meta_checktxnid()` to avoid assertion in debug mode.
|
||||||
|
|
||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
12
src/core.c
12
src/core.c
@ -7724,7 +7724,7 @@ __cold int mdbx_thread_unregister(const MDBX_env *env) {
|
|||||||
/* check against todo4recovery://erased_by_github/libmdbx/issues/269 */
|
/* check against todo4recovery://erased_by_github/libmdbx/issues/269 */
|
||||||
static bool meta_checktxnid(const MDBX_env *env, const MDBX_meta *meta,
|
static bool meta_checktxnid(const MDBX_env *env, const MDBX_meta *meta,
|
||||||
bool report) {
|
bool report) {
|
||||||
const txnid_t meta_txnid = constmeta_txnid(env, meta);
|
const txnid_t head_txnid = meta_txnid(env, meta);
|
||||||
const txnid_t freedb_mod_txnid = meta->mm_dbs[FREE_DBI].md_mod_txnid;
|
const txnid_t freedb_mod_txnid = meta->mm_dbs[FREE_DBI].md_mod_txnid;
|
||||||
const txnid_t maindb_mod_txnid = meta->mm_dbs[MAIN_DBI].md_mod_txnid;
|
const txnid_t maindb_mod_txnid = meta->mm_dbs[MAIN_DBI].md_mod_txnid;
|
||||||
|
|
||||||
@ -7741,25 +7741,25 @@ static bool meta_checktxnid(const MDBX_env *env, const MDBX_meta *meta,
|
|||||||
const uint64_t magic_and_version =
|
const uint64_t magic_and_version =
|
||||||
unaligned_peek_u64(4, &meta->mm_magic_and_version);
|
unaligned_peek_u64(4, &meta->mm_magic_and_version);
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
if (unlikely(meta_txnid < freedb_mod_txnid ||
|
if (unlikely(!head_txnid || head_txnid < freedb_mod_txnid ||
|
||||||
(!freedb_mod_txnid && freedb_root &&
|
(!freedb_mod_txnid && freedb_root &&
|
||||||
likely(magic_and_version == MDBX_DATA_MAGIC)))) {
|
likely(magic_and_version == MDBX_DATA_MAGIC)))) {
|
||||||
if (report)
|
if (report)
|
||||||
mdbx_warning(
|
mdbx_warning(
|
||||||
"catch invalid %sdb.mod_txnid %" PRIaTXN " for meta_txnid %" PRIaTXN
|
"catch invalid %sdb.mod_txnid %" PRIaTXN " for meta_txnid %" PRIaTXN
|
||||||
" %s",
|
" %s",
|
||||||
"free", freedb_mod_txnid, meta_txnid,
|
"free", freedb_mod_txnid, head_txnid,
|
||||||
"(workaround for incoherent flaw of unified page/buffer cache)");
|
"(workaround for incoherent flaw of unified page/buffer cache)");
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
if (unlikely(meta_txnid < maindb_mod_txnid ||
|
if (unlikely(head_txnid < maindb_mod_txnid ||
|
||||||
(!maindb_mod_txnid && maindb_root &&
|
(!maindb_mod_txnid && maindb_root &&
|
||||||
likely(magic_and_version == MDBX_DATA_MAGIC)))) {
|
likely(magic_and_version == MDBX_DATA_MAGIC)))) {
|
||||||
if (report)
|
if (report)
|
||||||
mdbx_warning(
|
mdbx_warning(
|
||||||
"catch invalid %sdb.mod_txnid %" PRIaTXN " for meta_txnid %" PRIaTXN
|
"catch invalid %sdb.mod_txnid %" PRIaTXN " for meta_txnid %" PRIaTXN
|
||||||
" %s",
|
" %s",
|
||||||
"main", maindb_mod_txnid, meta_txnid,
|
"main", maindb_mod_txnid, head_txnid,
|
||||||
"(workaround for incoherent flaw of unified page/buffer cache)");
|
"(workaround for incoherent flaw of unified page/buffer cache)");
|
||||||
ok = false;
|
ok = false;
|
||||||
}
|
}
|
||||||
@ -7800,7 +7800,7 @@ static bool meta_checktxnid(const MDBX_env *env, const MDBX_meta *meta,
|
|||||||
* for todo4recovery://erased_by_github/libmdbx/issues/269 */
|
* for todo4recovery://erased_by_github/libmdbx/issues/269 */
|
||||||
static int meta_waittxnid(const MDBX_env *env, const MDBX_meta *meta,
|
static int meta_waittxnid(const MDBX_env *env, const MDBX_meta *meta,
|
||||||
uint64_t *timestamp) {
|
uint64_t *timestamp) {
|
||||||
if (likely(meta_checktxnid(env, (const MDBX_meta *)meta, !*timestamp)))
|
if (likely(meta_checktxnid(env, meta, !*timestamp)))
|
||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
|
|
||||||
if (!*timestamp)
|
if (!*timestamp)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user