From 194f2f45d27b54498951e50f8409e48629f3f312 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Sat, 9 Jul 2022 18:07:54 +0300 Subject: [PATCH] mdbx: refine/fix using nested cursor's db inside copy-with-compactification. --- src/core.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 354fd730..d950402f 100644 --- a/src/core.c +++ b/src/core.c @@ -19839,8 +19839,15 @@ __cold static int compacting_walk_tree(mdbx_compacting_ctx *ctx, &nested->md_root, mp->mp_txnid); } } else { + mdbx_cassert(mc, + (mc->mc_flags & C_SUB) == 0 && mc->mc_xcursor == 0); MDBX_cursor_couple *couple = - container_of(mc, MDBX_cursor_couple, inner.mx_cursor); + container_of(mc, MDBX_cursor_couple, outer); + mdbx_cassert(mc, couple->inner.mx_cursor.mc_signature == + ~MDBX_MC_LIVE && + !couple->inner.mx_cursor.mc_flags && + !couple->inner.mx_cursor.mc_db && + !couple->inner.mx_cursor.mc_dbx); nested = &couple->inner.mx_db; memcpy(nested, node_data(node), sizeof(MDBX_db)); rc = compacting_walk_sdb(ctx, nested); @@ -19908,6 +19915,8 @@ __cold static int compacting_walk_sdb(mdbx_compacting_ctx *ctx, MDBX_db *sdb) { return MDBX_SUCCESS; /* empty db */ MDBX_cursor_couple couple; + memset(&couple, 0, sizeof(couple)); + couple.inner.mx_cursor.mc_signature = ~MDBX_MC_LIVE; MDBX_dbx dbx = {.md_klen_min = INT_MAX}; uint8_t dbistate = DBI_VALID | DBI_AUDITED; int rc = mdbx_couple_init(&couple, ~0u, ctx->mc_txn, sdb, &dbx, &dbistate);