Revert "Prevent dropping of unchecked on restart if high unchecked (#1965)"

This reverts commit ecc571ca6d.
This commit is contained in:
SergiySW 2019-05-14 17:47:15 +03:00
commit 2174fd737b
2 changed files with 7 additions and 15 deletions

View file

@ -832,7 +832,6 @@ txn_tracking_enabled (txn_tracking_config_a.enable)
if (!error_a) if (!error_a)
{ {
auto is_fully_upgraded (false); auto is_fully_upgraded (false);
bool is_unchecked_drop_required (false);
{ {
auto transaction (tx_begin_read ()); auto transaction (tx_begin_read ());
auto err = mdb_dbi_open (env.tx (transaction), "meta", 0, &meta); 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); error_a |= do_upgrades (transaction, batch_size);
} }
is_unchecked_drop_required = (block_count (transaction).sum () / 10) > unchecked_count (transaction) && unchecked_count (transaction) != 0;
} }
else else
{ {
auto transaction (tx_begin_read ()); auto transaction (tx_begin_read ());
open_databases (error_a, transaction, 0); 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)
if (!error_a && drop_unchecked && is_unchecked_drop_required)
{ {
auto transaction (tx_begin_write ()); auto transaction (tx_begin_write ());
unchecked_clear (transaction); unchecked_clear (transaction);

View file

@ -1847,18 +1847,14 @@ void nano::node::unchecked_cleanup ()
{ {
auto now (nano::seconds_since_epoch ()); auto now (nano::seconds_since_epoch ());
auto transaction (store.tx_begin_read ()); auto transaction (store.tx_begin_read ());
// Don't start cleanup if unchecked count > 10% of total blocks count // Max 128k records to clean, max 2 minutes reading to prevent slow i/o systems start issues
if ((store.block_count (transaction).sum () / 10) + 1 >= store.unchecked_count (transaction)) 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 nano::unchecked_key key (i->first);
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_info info (i->second);
if ((now - info.modified) > static_cast<uint64_t> (config.unchecked_cutoff_time.count ()))
{ {
nano::unchecked_key key (i->first); cleaning_list.push_back (key);
nano::unchecked_info info (i->second);
if ((now - info.modified) > static_cast<uint64_t> (config.unchecked_cutoff_time.count ()))
{
cleaning_list.push_back (key);
}
} }
} }
} }