From: Miod Vallat Date: Mon, 27 Jan 2025 15:10:37 +0000 (+0100) Subject: Fix "Duplicate RW transaction" LMDB exception. X-Git-Tag: dnsdist-2.0.0-alpha1~46^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e36e27e83cd431e1ecdcf0edd8d696b9f5140c8c;p=thirdparty%2Fpdns.git Fix "Duplicate RW transaction" LMDB exception. The check was too strict and would prevent any RO transaction to coexist with RW transactions. But LMDB is designed to allow this - on the other hand there can be only one active RW transaction at a time. --- diff --git a/ext/lmdb-safe/lmdb-safe.cc b/ext/lmdb-safe/lmdb-safe.cc index f0db35fd81..7c4f2d300a 100644 --- a/ext/lmdb-safe/lmdb-safe.cc +++ b/ext/lmdb-safe/lmdb-safe.cc @@ -235,8 +235,9 @@ MDBRWTransactionImpl::MDBRWTransactionImpl(MDBEnv *parent, MDB_txn *txn): MDB_txn *MDBRWTransactionImpl::openRWTransaction(MDBEnv *env, MDB_txn *parent, int flags) { MDB_txn *result; - if(env->getROTX() || env->getRWTX()) + if(env->getRWTX() != 0) { throw std::runtime_error("Duplicate RW transaction"); + } if(int rc=mdb_txn_begin(env->d_env, parent, flags, &result)) throw std::runtime_error("Unable to start RW transaction: "+std::string(mdb_strerror(rc)));