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] 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);