Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lmdb txn commit code #9290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix lmdb txn commit code
  • Loading branch information
vtnerd committed Jun 4, 2024
commit d64a5f70d246afe3b8d796b65f0e58f40bb1dcad
5 changes: 3 additions & 2 deletions src/lmdb/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,10 @@ namespace lmdb
expect<void> 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
9 changes: 6 additions & 3 deletions src/lmdb/database.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading