From ef0bbb44629f93e64d471545f4fef9826288ff53 Mon Sep 17 00:00:00 2001 From: Martchus Date: Sat, 25 Dec 2021 22:54:46 +0100 Subject: [PATCH] Handle errors when committing transaction --- lmdb-safe.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lmdb-safe.cc b/lmdb-safe.cc index 2a42fa0..980d91c 100644 --- a/lmdb-safe.cc +++ b/lmdb-safe.cc @@ -292,7 +292,9 @@ void MDBROTransactionImpl::commit() // if d_txn is non-nullptr here, either the transaction object was invalidated earlier (e.g. by moving from it), or it is an RW transaction which has already cleaned up the d_txn pointer (with an abort). if (d_txn) { d_parent->decROTX(); - mdb_txn_commit(d_txn); // this appears to work better than abort for r/o database opening + if (const auto rc = mdb_txn_commit(d_txn)) { // this appears to work better than abort for r/o database opening + throw std::runtime_error("Error comitting transaction: " + MDBError(rc)); + } d_txn = nullptr; } }