From d64a5f70d246afe3b8d796b65f0e58f40bb1dcad Mon Sep 17 00:00:00 2001 From: Lee *!* Clagett Date: Tue, 4 Jun 2024 18:55:39 -0400 Subject: [PATCH] Fix lmdb txn commit code --- src/lmdb/database.cpp | 5 +++-- src/lmdb/database.h | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lmdb/database.cpp b/src/lmdb/database.cpp index 22569fcf0..0da88622a 100644 --- a/src/lmdb/database.cpp +++ b/src/lmdb/database.cpp @@ -179,9 +179,10 @@ namespace lmdb expect database::commit(write_txn txn) noexcept { MONERO_PRECOND(txn != nullptr); - MONERO_LMDB_CHECK(mdb_txn_commit(txn.get())); - txn.release(); + const int err = mdb_txn_commit(txn.release()); release_context(ctx); + if (err) + return {lmdb::error(err)}; return success(); } } // lmdb diff --git a/src/lmdb/database.h b/src/lmdb/database.h index 0f12571da..608bc4571 100644 --- a/src/lmdb/database.h +++ b/src/lmdb/database.h @@ -123,10 +123,13 @@ namespace lmdb const auto wrote = f(*(*txn)); if (wrote) { - MONERO_CHECK(commit(std::move(*txn))); - return wrote; + const auto committed = commit(std::move(*txn)); + if (committed) + return wrote; + if (committed != lmdb::error(MDB_MAP_FULL)) + return committed.error(); } - if (wrote != lmdb::error(MDB_MAP_FULL)) + else if (wrote != lmdb::error(MDB_MAP_FULL)) return wrote; txn->reset();