Skip to content

Commit

Permalink
Fix "Duplicate RW transaction" LMDB exception.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
miodvallat committed Jan 27, 2025
1 parent 0ce41bc commit e36e27e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ext/lmdb-safe/lmdb-safe.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down

0 comments on commit e36e27e

Please sign in to comment.