diff --git a/nano/store/rocksdb/rocksdb.cpp b/nano/store/rocksdb/rocksdb.cpp index 391364fa8a..dcfd84451b 100644 --- a/nano/store/rocksdb/rocksdb.cpp +++ b/nano/store/rocksdb/rocksdb.cpp @@ -420,6 +420,7 @@ std::vector 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 (transaction_db) }; } @@ -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; diff --git a/nano/store/rocksdb/rocksdb.hpp b/nano/store/rocksdb/rocksdb.hpp index 1d964b8ee1..25f29b2a0f 100644 --- a/nano/store/rocksdb/rocksdb.hpp +++ b/nano/store/rocksdb/rocksdb.hpp @@ -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;