From b8bb4b4cc415e2ac5e814c790d41c540dbdc32ce Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Wed, 6 Jan 2021 16:09:11 +0300 Subject: [PATCH] mdbx: fix propagation child txn DBI-state to parent. Change-Id: I7d92fa99131a937af1a1a75b38af57bc6787ab37 --- src/core.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core.c b/src/core.c index 74c45926..ad545653 100644 --- a/src/core.c +++ b/src/core.c @@ -8295,9 +8295,14 @@ int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency) { parent->mt_dbistate[FREE_DBI] = txn->mt_dbistate[FREE_DBI]; parent->mt_dbistate[MAIN_DBI] = txn->mt_dbistate[MAIN_DBI]; for (unsigned i = CORE_DBS; i < txn->mt_numdbs; i++) { - /* preserve parent's DB_NEW status */ - parent->mt_dbistate[i] = txn->mt_dbistate[i] | (parent->mt_dbistate[i] & - (DBI_CREAT | DBI_FRESH)); + /* preserve parent's status */ + const uint8_t state = + txn->mt_dbistate[i] | + (parent->mt_dbistate[i] & (DBI_CREAT | DBI_FRESH | DBI_DIRTY)); + mdbx_debug("db %u dbi-state %s 0x%02x -> 0x%02x", i, + (parent->mt_dbistate[i] != state) ? "update" : "still", + parent->mt_dbistate[i], state); + parent->mt_dbistate[i] = state; } ts_1 = latency ? mdbx_osal_monotime() : 0; @@ -8537,6 +8542,9 @@ int mdbx_txn_commit_ex(MDBX_txn *txn, MDBX_commit_latency *latency) { goto fail; } MDBX_db *db = &txn->mt_dbs[i]; + mdbx_debug("update main's entry for sub-db %u, mod_txnid %" PRIaTXN + " -> %" PRIaTXN, + i, pp_txnid2chk(txn), db->md_mod_txnid); db->md_mod_txnid = pp_txnid2chk(txn); data.iov_base = db; WITH_CURSOR_TRACKING(couple.outer,