Skip to content

Commit

Permalink
Add single transaction sanity check.
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Sep 28, 2024
1 parent dbdf1b1 commit f929415
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions nano/store/rocksdb/rocksdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ std::vector<rocksdb::ColumnFamilyDescriptor> nano::store::rocksdb::component::cr
nano::store::write_transaction nano::store::rocksdb::component::tx_begin_write ()
{
release_assert (transaction_db != nullptr);
debug_assert (check_no_write_tx ());
return store::write_transaction{ std::make_unique<nano::store::rocksdb::write_transaction_impl> (transaction_db) };
}

Expand Down Expand Up @@ -862,6 +863,13 @@ bool nano::store::rocksdb::component::init_error () const
return error;
}

bool nano::store::rocksdb::component::check_no_write_tx () const
{
std::vector<::rocksdb::Transaction *> transactions;
transaction_db->GetAllPreparedTransactions (&transactions);
return transactions.empty ();
}

void nano::store::rocksdb::component::serialize_memory_stats (boost::property_tree::ptree & json)
{
uint64_t val;
Expand Down
1 change: 1 addition & 0 deletions nano/store/rocksdb/rocksdb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class component : public nano::store::component
std::string error_string (int status) const override;

private:
bool check_no_write_tx () const;
bool error{ false };
nano::logger & logger;
nano::ledger_constants & constants;
Expand Down

0 comments on commit f929415

Please sign in to comment.