Skip to content

Commit

Permalink
[RocksDB] Limit write locks to necessary tables (#2592)
Browse files Browse the repository at this point in the history
  • Loading branch information
wezrule committed Feb 24, 2020
1 parent 3c8ae09 commit 15de571
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion nano/node/json_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4096,7 +4096,7 @@ void nano::json_handler::unchecked_clear ()
{
auto rpc_l (shared_from_this ());
node.worker.push_task ([rpc_l]() {
auto transaction (rpc_l->node.store.tx_begin_write ());
auto transaction (rpc_l->node.store.tx_begin_write ({ tables::unchecked }));
rpc_l->node.store.unchecked_clear (transaction);
rpc_l->node.ledger.cache.unchecked_count = 0;
rpc_l->response_l.put ("success", "");
Expand Down
10 changes: 5 additions & 5 deletions nano/node/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ startup_time (std::chrono::steady_clock::now ())
if (!is_initialized)
{
release_assert (!flags.read_only);
auto transaction (store.tx_begin_write ());
auto transaction (store.tx_begin_write ({ tables::accounts, tables::cached_counts, tables::confirmation_height, tables::frontiers, tables::open_blocks }));
// Store was empty meaning we just created it, add the genesis block
store.initialize (transaction, genesis, ledger.cache);
}
Expand Down Expand Up @@ -441,7 +441,7 @@ startup_time (std::chrono::steady_clock::now ())
// Drop unchecked blocks if initial bootstrap is completed
if (!flags.disable_unchecked_drop && !use_bootstrap_weight && !flags.read_only)
{
auto transaction (store.tx_begin_write ());
auto transaction (store.tx_begin_write ({ tables::unchecked }));
store.unchecked_clear (transaction);
ledger.cache.unchecked_count = 0;
logger.always_log ("Dropping unchecked blocks");
Expand Down Expand Up @@ -626,7 +626,7 @@ nano::process_return nano::node::process_local (std::shared_ptr<nano::block> blo
// Notify block processor to release write lock
block_processor.wait_write ();
// Process block
auto transaction (store.tx_begin_write ());
auto transaction (store.tx_begin_write ({ tables::accounts, tables::cached_counts, tables::change_blocks, tables::frontiers, tables::open_blocks, tables::pending, tables::receive_blocks, tables::representation, tables::send_blocks, tables::state_blocks }, { tables::confirmation_height }));
return block_processor.process_one (transaction, info, work_watcher_a);
}

Expand Down Expand Up @@ -780,7 +780,7 @@ nano::uint128_t nano::node::minimum_principal_weight (nano::uint128_t const & on
void nano::node::long_inactivity_cleanup ()
{
bool perform_cleanup = false;
auto transaction (store.tx_begin_write ());
auto transaction (store.tx_begin_write ({ tables::online_weight, tables::peers }));
if (store.online_weight_count (transaction) > 0)
{
auto i (store.online_weight_begin (transaction));
Expand Down Expand Up @@ -950,7 +950,7 @@ void nano::node::unchecked_cleanup ()
while (!cleaning_list.empty ())
{
size_t deleted_count (0);
auto transaction (store.tx_begin_write ());
auto transaction (store.tx_begin_write ({ tables::unchecked }));
while (deleted_count++ < 2 * 1024 && !cleaning_list.empty ())
{
auto key (cleaning_list.front ());
Expand Down
2 changes: 1 addition & 1 deletion nano/node/online_reps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void nano::online_reps::observe (nano::account const & rep_a)

void nano::online_reps::sample ()
{
auto transaction (ledger.store.tx_begin_write ());
auto transaction (ledger.store.tx_begin_write ({ tables::online_weight }));
// Discard oldest entries
while (ledger.store.online_weight_count (transaction) >= network_params.node.max_weight_samples)
{
Expand Down

0 comments on commit 15de571

Please sign in to comment.