From 2ceda89b055a749d649c67279ab114e11d86d569 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: Thu, 10 Apr 2025 12:14:53 +0300 Subject: [PATCH] =?UTF-8?q?mdbx-tests:=20=D1=80=D0=B0=D1=81=D1=88=D0=B8?= =?UTF-8?q?=D1=80=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B8=20=D0=B4=D0=BE=D1=80?= =?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=82=D0=BA=D0=B0=20=D1=81=D1=86=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=D1=80=D0=B8=D1=8F=20extra/cursor-closing.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/extra/cursor_closing.c++ | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/test/extra/cursor_closing.c++ b/test/extra/cursor_closing.c++ index 4bd4b7ca..2a0184a6 100644 --- a/test/extra/cursor_closing.c++ +++ b/test/extra/cursor_closing.c++ @@ -172,9 +172,21 @@ mdbx::map_handle case1_cycle_dbi(std::deque &dbi) { void case1_read_cycle(mdbx::txn txn, std::deque &dbi, std::vector &pool, mdbx::cursor pre, bool nested = false) { - for (auto c : pool) - mdbx::cursor(c).bind(txn, case1_cycle_dbi(dbi)); - pre.bind(txn, case1_cycle_dbi(dbi)); + if (nested) { + for (auto c : pool) + try { + mdbx::cursor(c).bind(txn, case1_cycle_dbi(dbi)); + } catch (const std::invalid_argument &) { + } + try { + pre.bind(txn, case1_cycle_dbi(dbi)); + } catch (const std::invalid_argument &) { + } + } else { + for (auto c : pool) + mdbx::cursor(c).bind(txn, case1_cycle_dbi(dbi)); + pre.bind(txn, case1_cycle_dbi(dbi)); + } for (auto n = prng(3 + dbi.size()); n > 0; --n) { auto c = txn.open_cursor(dbi[prng(dbi.size())]); @@ -215,6 +227,16 @@ void case1_read_cycle(mdbx::txn txn, std::deque &dbi, std::vec switch (prng(nested ? 7 : 3)) { case 0: + if (pre.txn()) { + if (nested) + try { + pre.unbind(); + } catch (const std::invalid_argument &) { + return; + } + else + pre.unbind(); + } for (auto i = pool.begin(); i != pool.end();) if (mdbx_cursor_txn(*i)) i = pool.erase(i); @@ -253,6 +275,8 @@ void case1_write_cycle(mdbx::txn_managed txn, std::deque &dbi, if (prng(16) > 8) case1_write_cycle(txn.start_nested(), dbi, pool, pre, true); + case1_read_cycle(txn, dbi, pool, pre, nested); + if (flipcoin()) txn.commit(); else