From 9f0e2ecc6787068d3a96dac59e15f81ec9694947 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: Fri, 12 Aug 2022 20:19:31 +0300 Subject: [PATCH 1/5] mdbx: fix variable name typo. --- src/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 0dc38fba..4e2fd053 100644 --- a/src/core.c +++ b/src/core.c @@ -12438,7 +12438,7 @@ __cold static int mdbx_setup_dxb(MDBX_env *env, const int lck_rc, } else { const txnid_t txnid = constmeta_txnid(env, head); const txnid_t next_txnid = safe64_txnid_next(txnid); - if (unlikely(txnid > MAX_TXNID)) { + if (unlikely(next_txnid > MAX_TXNID)) { mdbx_error("txnid overflow, raise %d", MDBX_TXN_FULL); return MDBX_TXN_FULL; } From 8467cc6d03f0d6fb819d27fc5590f5615a8e6535 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, 13 Aug 2022 16:52:43 +0300 Subject: [PATCH 2/5] mdbx: use current txn geo for untouched parameters when `env_set_geometry()` called within a write transaction. --- src/core.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/core.c b/src/core.c index 4e2fd053..cfb122f7 100644 --- a/src/core.c +++ b/src/core.c @@ -11671,38 +11671,40 @@ mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, if (unlikely(env->me_flags & MDBX_RDONLY)) return MDBX_EACCESS; - if (!inside_txn) { + const MDBX_geo *geo = nullptr; + if (inside_txn) + geo = &env->me_txn->mt_geo; + else { int err = mdbx_txn_lock(env, false); if (unlikely(err != MDBX_SUCCESS)) return err; need_unlock = true; - } - const MDBX_meta *head = constmeta_prefer_last(env); - if (!inside_txn) { + + const MDBX_meta *head = constmeta_prefer_last(env); + geo = &head->mm_geo; env->me_txn0->mt_txnid = constmeta_txnid(env, head); mdbx_find_oldest(env->me_txn0); } - /* get untouched params from DB */ + /* get untouched params from current write-txn or DB */ if (pagesize <= 0 || pagesize >= INT_MAX) pagesize = env->me_psize; if (size_lower < 0) - size_lower = pgno2bytes(env, head->mm_geo.lower); + size_lower = pgno2bytes(env, geo->lower); if (size_now < 0) - size_now = pgno2bytes(env, head->mm_geo.now); + size_now = pgno2bytes(env, geo->now); if (size_upper < 0) - size_upper = pgno2bytes(env, head->mm_geo.upper); + size_upper = pgno2bytes(env, geo->upper); if (growth_step < 0) - growth_step = pgno2bytes(env, pv2pages(head->mm_geo.grow_pv)); + growth_step = pgno2bytes(env, pv2pages(geo->grow_pv)); if (shrink_threshold < 0) - shrink_threshold = pgno2bytes(env, pv2pages(head->mm_geo.shrink_pv)); + shrink_threshold = pgno2bytes(env, pv2pages(geo->shrink_pv)); if (pagesize != (intptr_t)env->me_psize) { rc = MDBX_EINVAL; goto bailout; } - const size_t usedbytes = - pgno2bytes(env, mdbx_find_largest(env, head->mm_geo.next)); + const size_t usedbytes = pgno2bytes(env, mdbx_find_largest(env, geo->next)); if ((size_t)size_upper < usedbytes) { rc = MDBX_MAP_FULL; goto bailout; From 3fbbe32adf6f6708ac456b5109f18c8292da1058 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: Sun, 14 Aug 2022 12:39:21 +0300 Subject: [PATCH 3/5] mdbx: fix checking owner for finished write transactions inside `txn_abort()`. Fixed regression after 06734bf8ffd94842b13e72cc65836f347fa585f0. --- src/core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index cfb122f7..164be24b 100644 --- a/src/core.c +++ b/src/core.c @@ -8152,8 +8152,10 @@ static __always_inline int check_txn(const MDBX_txn *txn, int bad_bits) { ? txn->mt_env->me_flags & MDBX_NOTLS : 0)); #if MDBX_TXN_CHECKOWNER + STATIC_ASSERT(MDBX_NOTLS > MDBX_TXN_FINISHED + MDBX_TXN_RDONLY); if (unlikely(txn->mt_owner != mdbx_thread_self()) && - (txn->mt_flags & (MDBX_NOTLS | MDBX_TXN_FINISHED)) == 0) + (txn->mt_flags & (MDBX_NOTLS | MDBX_TXN_FINISHED | MDBX_TXN_RDONLY)) < + (MDBX_TXN_FINISHED | MDBX_TXN_RDONLY)) return txn->mt_owner ? MDBX_THREAD_MISMATCH : MDBX_BAD_TXN; #endif /* MDBX_TXN_CHECKOWNER */ @@ -8958,6 +8960,9 @@ int mdbx_txn_abort(MDBX_txn *txn) { return mdbx_txn_end(txn, MDBX_END_ABORT | MDBX_END_UPDATE | MDBX_END_SLOT | MDBX_END_FREE); + if (unlikely(txn->mt_flags & MDBX_TXN_FINISHED)) + return MDBX_BAD_TXN; + if (txn->mt_child) mdbx_txn_abort(txn->mt_child); From 316ddf9e01ff6c360b5d2b46ddbf63d02c1ace63 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: Tue, 16 Aug 2022 11:08:04 +0300 Subject: [PATCH 4/5] mdbx: fix typo in `MDBX_EINVAL` which breaks MingGW builds with CLANG. --- src/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core.c b/src/core.c index 164be24b..a8d57100 100644 --- a/src/core.c +++ b/src/core.c @@ -15253,7 +15253,7 @@ int mdbx_cursor_get_batch(MDBX_cursor *mc, size_t *count, MDBX_val *pairs, break; default: mdbx_debug("unhandled/unimplemented cursor operation %u", op); - rc = EINVAL; + rc = MDBX_EINVAL; break; } From 4f021996485fc1cc3143edee58995e96ad786f10 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: Wed, 17 Aug 2022 23:56:53 +0300 Subject: [PATCH 5/5] mdbx: update ChangeLog. --- ChangeLog.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/ChangeLog.md b/ChangeLog.md index 5d262e4e..1383c4e0 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,6 +1,32 @@ ChangeLog --------- +## v0.11.+ + +Bugfixing within the stable `master` branch. + +New: + + - The C++ API has been refined to simplify support for `wchar_t` in path names. + +Fixes: + + - Never use modern `__cxa_thread_atexit()` on Apple's OSes. + - Use `MultiByteToWideChar(CP_THREAD_ACP)` instead of `mbstowcs()`. + - Don't check owner for finished transactions. + - Fixed typo in `MDBX_EINVAL` which breaks MingGW builds with CLANG. + +Minors: + + - Fixed variable name typo. + - Using `ldd` to check used dso. + - Added `MDBX_WEAK_IMPORT_ATTRIBUTE` macro. + - Use current transaction geometry for untouched parameters when `env_set_geometry()` called within a write transaction. + + +------------------------------------------------------------------------------- + + ## v0.11.9 (Чирчик-1992) at 2022-08-02 The stable bugfix release.