diff --git a/nano/node/lmdb.cpp b/nano/node/lmdb.cpp index ec9c18dc3..b7ae9f68b 100644 --- a/nano/node/lmdb.cpp +++ b/nano/node/lmdb.cpp @@ -832,7 +832,6 @@ txn_tracking_enabled (txn_tracking_config_a.enable) if (!error_a) { auto is_fully_upgraded (false); - bool is_unchecked_drop_required (false); { auto transaction (tx_begin_read ()); auto err = mdb_dbi_open (env.tx (transaction), "meta", 0, &meta); @@ -854,17 +853,14 @@ txn_tracking_enabled (txn_tracking_config_a.enable) { error_a |= do_upgrades (transaction, batch_size); } - is_unchecked_drop_required = (block_count (transaction).sum () / 10) > unchecked_count (transaction) && unchecked_count (transaction) != 0; } else { auto transaction (tx_begin_read ()); open_databases (error_a, transaction, 0); - is_unchecked_drop_required = (block_count (transaction).sum () / 10) > unchecked_count (transaction) && unchecked_count (transaction) != 0; } - // Delete unchecked blocks at node start (if node initial synchronization is mostly completed) - if (!error_a && drop_unchecked && is_unchecked_drop_required) + if (!error_a && drop_unchecked) { auto transaction (tx_begin_write ()); unchecked_clear (transaction); diff --git a/nano/node/node.cpp b/nano/node/node.cpp index 361a98472..27f0eb301 100644 --- a/nano/node/node.cpp +++ b/nano/node/node.cpp @@ -1847,18 +1847,14 @@ void nano::node::unchecked_cleanup () { auto now (nano::seconds_since_epoch ()); auto transaction (store.tx_begin_read ()); - // Don't start cleanup if unchecked count > 10% of total blocks count - if ((store.block_count (transaction).sum () / 10) + 1 >= store.unchecked_count (transaction)) + // Max 128k records to clean, max 2 minutes reading to prevent slow i/o systems start issues + for (auto i (store.unchecked_begin (transaction)), n (store.unchecked_end ()); i != n && cleaning_list.size () < 128 * 1024 && nano::seconds_since_epoch () - now < 120; ++i) { - // Max 128k records to clean, max 2 minutes reading to prevent slow i/o systems start issues - for (auto i (store.unchecked_begin (transaction)), n (store.unchecked_end ()); i != n && cleaning_list.size () < 128 * 1024 && nano::seconds_since_epoch () - now < 120; ++i) + nano::unchecked_key key (i->first); + nano::unchecked_info info (i->second); + if ((now - info.modified) > static_cast (config.unchecked_cutoff_time.count ())) { - nano::unchecked_key key (i->first); - nano::unchecked_info info (i->second); - if ((now - info.modified) > static_cast (config.unchecked_cutoff_time.count ())) - { - cleaning_list.push_back (key); - } + cleaning_list.push_back (key); } } }