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 rocksdb_block_store.tombstone_count #3850

Merged
merged 1 commit into from
Jul 9, 2022
Merged
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
54 changes: 28 additions & 26 deletions nano/core_test/block_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2645,34 +2645,36 @@ namespace nano
// logic bound to the way RocksDB is used by the node.
TEST (rocksdb_block_store, tombstone_count)
{
if (nano::rocksdb_config::using_rocksdb_in_tests ())
if (!nano::rocksdb_config::using_rocksdb_in_tests ())
{
nano::system system{};
nano::logger_mt logger{};
auto store = std::make_unique<nano::rocksdb::store> (logger, nano::unique_path (), nano::dev::constants);
nano::unchecked_map unchecked{ *store, false };
ASSERT_TRUE (!store->init_error ());
nano::block_builder builder;
auto block = builder
.send ()
.previous (0)
.destination (1)
.balance (2)
.sign (nano::keypair ().prv, 4)
.work (5)
.build_shared ();
// Enqueues a block to be saved in the database
unchecked.put (block->previous (), nano::unchecked_info (block));
auto check_block_is_listed = [&] (nano::transaction const & transaction_a, nano::block_hash const & block_hash_a) {
return unchecked.get (transaction_a, block_hash_a).size () > 0;
};
// Waits for the block to get saved
ASSERT_TIMELY (5s, check_block_is_listed (store->tx_begin_read (), block->previous ()));
ASSERT_EQ (store->tombstone_map.at (nano::tables::unchecked).num_since_last_flush.load (), 0);
// Perorms a delete and checks for the tombstone counter
unchecked.del (store->tx_begin_write (), nano::unchecked_key (block->previous (), block->hash ()));
ASSERT_EQ (store->tombstone_map.at (nano::tables::unchecked).num_since_last_flush.load (), 1);
return;
clemahieu marked this conversation as resolved.
Show resolved Hide resolved
}
nano::system system{};
nano::logger_mt logger;
auto store = std::make_unique<nano::rocksdb::store> (logger, nano::unique_path (), nano::dev::constants);
ASSERT_TRUE (!store->init_error ());
nano::block_builder builder;
auto block = builder
.send ()
.previous (0)
.destination (1)
.balance (2)
.sign (nano::keypair ().prv, 4)
.work (5)
.build_shared ();
// Enqueues a block to be saved in the database
auto previous = block->previous ();
store->unchecked.put (store->tx_begin_write (), previous, nano::unchecked_info (block));
nano::unchecked_key key{ previous, block->hash () };
auto check_block_is_listed = [&] (nano::transaction const & transaction_a) {
return store->unchecked.exists (transaction_a, key);
};
// Waits for the block to get saved
ASSERT_TIMELY (5s, check_block_is_listed (store->tx_begin_read ()));
ASSERT_EQ (store->tombstone_map.at (nano::tables::unchecked).num_since_last_flush.load (), 0);
// Perorms a delete and checks for the tombstone counter
store->unchecked.del (store->tx_begin_write (), nano::unchecked_key (previous, block->hash ()));
ASSERT_TIMELY (5s, store->tombstone_map.at (nano::tables::unchecked).num_since_last_flush.load () == 1);
}
}

Expand Down
2 changes: 2 additions & 0 deletions nano/secure/store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,8 @@ class unchecked_map;
*/
class store
{
friend class rocksdb_block_store_tombstone_count_Test;

public:
// clang-format off
explicit store (
Expand Down