Merge pull request #9290

d64a5f7 Fix lmdb txn commit code (Lee *!* Clagett)
This commit is contained in:
luigi1111 2024-12-23 10:25:10 -05:00
commit 6796e99438
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
2 changed files with 9 additions and 5 deletions

View file

@ -179,9 +179,10 @@ namespace lmdb
expect<void> database::commit(write_txn txn) noexcept expect<void> database::commit(write_txn txn) noexcept
{ {
MONERO_PRECOND(txn != nullptr); MONERO_PRECOND(txn != nullptr);
MONERO_LMDB_CHECK(mdb_txn_commit(txn.get())); const int err = mdb_txn_commit(txn.release());
txn.release();
release_context(ctx); release_context(ctx);
if (err)
return {lmdb::error(err)};
return success(); return success();
} }
} // lmdb } // lmdb

View file

@ -123,10 +123,13 @@ namespace lmdb
const auto wrote = f(*(*txn)); const auto wrote = f(*(*txn));
if (wrote) if (wrote)
{ {
MONERO_CHECK(commit(std::move(*txn))); const auto committed = commit(std::move(*txn));
return wrote; 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; return wrote;
txn->reset(); txn->reset();