diff --git a/src/cursor.c b/src/cursor.c index 22442e05..766943f7 100644 --- a/src/cursor.c +++ b/src/cursor.c @@ -168,7 +168,7 @@ __hot int cursor_touch(MDBX_cursor *const mc, const MDBX_val *key, const MDBX_va return err; } - if (likely(mc->top >= 0) && !is_modifable(mc->txn, mc->pg[mc->top])) { + if (likely(is_pointed(mc)) && ((mc->txn->flags & MDBX_TXN_SPILLS) || !is_modifable(mc->txn, mc->pg[mc->top]))) { const int8_t top = mc->top; mc->top = 0; do { diff --git a/src/node.c b/src/node.c index f4b264fc..f7676eaf 100644 --- a/src/node.c +++ b/src/node.c @@ -50,6 +50,7 @@ int __must_check_result node_add_branch(MDBX_cursor *mc, size_t indx, const MDBX is_subpage(mp) ? "sub-" : "", mp->pgno, indx, pgno, key ? key->iov_len : 0, DKEY_DEBUG(key)); cASSERT(mc, page_type(mp) == P_BRANCH); + cASSERT(mc, mp->txnid >= mc->txn->front_txnid); STATIC_ASSERT(NODESIZE % 2 == 0); /* Move higher pointers up one slot. */ diff --git a/src/page-get.c b/src/page-get.c index ad3ed3c1..2646eb0e 100644 --- a/src/page-get.c +++ b/src/page-get.c @@ -457,6 +457,8 @@ static __always_inline pgr_t page_get_inline(const uint16_t ILL, const MDBX_curs goto bailout; } + TRACE("dbi %zu, mc %p, page %u, %p", cursor_dbi(mc), __Wpedantic_format_voidptr(mc), pgno, + __Wpedantic_format_voidptr(r.page)); if (unlikely(mc->checking & z_pagecheck)) return check_page_complete(ILL, r.page, mc, front); diff --git a/src/spill.c b/src/spill.c index 29ce8d8a..af09d12d 100644 --- a/src/spill.c +++ b/src/spill.c @@ -72,6 +72,8 @@ static size_t spill_cursor_keep(const MDBX_txn *const txn, const MDBX_cursor *mc intptr_t i = 0; do { mp = mc->pg[i]; + TRACE("dbi %zu, mc-%p[%zu], page %u %p", cursor_dbi(mc), __Wpedantic_format_voidptr(mc), i, mp->pgno, + __Wpedantic_format_voidptr(mp)); tASSERT(txn, !is_subpage(mp)); if (is_modifable(txn, mp)) { size_t const n = dpl_search(txn, mp->pgno); @@ -81,16 +83,18 @@ static size_t spill_cursor_keep(const MDBX_txn *const txn, const MDBX_cursor *mc *ptr = txn->wr.dirtylru; tASSERT(txn, dpl_age(txn, n) == 0); ++keep; + DEBUG("keep page %" PRIaPGNO " (%p), dbi %zu, %scursor %p[%zu]", mp->pgno, __Wpedantic_format_voidptr(mp), + cursor_dbi(mc), is_inner(mc) ? "sub-" : "", __Wpedantic_format_voidptr(mc), i); } } } while (++i <= mc->top); tASSERT(txn, is_leaf(mp)); - if (!mc->subcur || mc->ki[mc->top] >= page_numkeys(mp)) - break; - if (!(node_flags(page_node(mp, mc->ki[mc->top])) & N_TREE)) + if (!inner_pointed(mc)) break; mc = &mc->subcur->cursor; + if (is_subpage(mc->pg[0])) + break; } return keep; }