mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-02 01:44:14 +08:00
mdbx: refine providing information for the @MAIN and @GC sub-databases of a last committed modification transaction's ID.
This commit is contained in:
parent
9dd15a4415
commit
cbb71058ca
19
src/core.c
19
src/core.c
@ -10057,9 +10057,6 @@ int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency) {
|
||||
ts_3 = latency ? mdbx_osal_monotime() : 0;
|
||||
|
||||
if (likely(rc == MDBX_SUCCESS)) {
|
||||
if (txn->mt_dbs[MAIN_DBI].md_flags & DBI_DIRTY)
|
||||
txn->mt_dbs[MAIN_DBI].md_mod_txnid = txn->mt_txnid;
|
||||
txn->mt_dbs[FREE_DBI].md_mod_txnid = txn->mt_txnid;
|
||||
|
||||
MDBX_meta meta, *head = mdbx_meta_head(env);
|
||||
memcpy(meta.mm_magic_and_version, head->mm_magic_and_version, 8);
|
||||
@ -10072,7 +10069,15 @@ int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency) {
|
||||
|
||||
meta.mm_geo = txn->mt_geo;
|
||||
meta.mm_dbs[FREE_DBI] = txn->mt_dbs[FREE_DBI];
|
||||
meta.mm_dbs[FREE_DBI].md_mod_txnid =
|
||||
(txn->mt_dbistate[FREE_DBI] & DBI_DIRTY)
|
||||
? txn->mt_txnid
|
||||
: txn->mt_dbs[FREE_DBI].md_mod_txnid;
|
||||
meta.mm_dbs[MAIN_DBI] = txn->mt_dbs[MAIN_DBI];
|
||||
meta.mm_dbs[MAIN_DBI].md_mod_txnid =
|
||||
(txn->mt_dbistate[MAIN_DBI] & DBI_DIRTY)
|
||||
? txn->mt_txnid
|
||||
: txn->mt_dbs[MAIN_DBI].md_mod_txnid;
|
||||
meta.mm_canary = txn->mt_canary;
|
||||
mdbx_meta_set_txnid(env, &meta, txn->mt_txnid);
|
||||
|
||||
@ -13150,7 +13155,7 @@ dirty:
|
||||
}
|
||||
|
||||
if (unlikely(ret.page->mp_txnid > front) &&
|
||||
(ret.page->mp_txnid > txn->mt_front || front < txn->mt_txnid)) {
|
||||
unlikely(ret.page->mp_txnid > txn->mt_front || front < txn->mt_txnid)) {
|
||||
bad_page(ret.page,
|
||||
"invalid page txnid (%" PRIaTXN ") for %s' txnid (%" PRIaTXN ")\n",
|
||||
ret.page->mp_txnid,
|
||||
@ -13404,11 +13409,13 @@ __hot static int mdbx_page_search(MDBX_cursor *mc, const MDBX_val *key,
|
||||
: mc->mc_txn->mt_txnid;
|
||||
MDBX_txn *scan = mc->mc_txn;
|
||||
do
|
||||
if (scan->mt_dbistate[mc->mc_dbi] & DBI_DIRTY) {
|
||||
if ((scan->mt_flags & MDBX_TXN_DIRTY) &&
|
||||
(mc->mc_dbi == MAIN_DBI ||
|
||||
(scan->mt_dbistate[mc->mc_dbi] & DBI_DIRTY))) {
|
||||
pp_txnid = scan->mt_front;
|
||||
break;
|
||||
}
|
||||
while ((scan = scan->mt_parent) != nullptr);
|
||||
while (unlikely((scan = scan->mt_parent) != nullptr));
|
||||
if (unlikely((rc = mdbx_page_get(mc, root, &mc->mc_pg[0], pp_txnid) != 0)))
|
||||
return rc;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user