From 94d2a811a167a05c43c323c171f8e19e5b6d3eae Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Sun, 8 Sep 2024 13:31:02 +0200 Subject: [PATCH 1/2] Show percentage progress during database migration --- nano/secure/ledger.cpp | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 66bd5ea018..d3bcbb7dce 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -1306,11 +1306,11 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p if (auto count_l = ++count; count_l % 5000000 == 0) { - logger.info (nano::log::type::ledger, "{} blocks converted", count_l); + logger.info (nano::log::type::ledger, "{} blocks converted ({}%)", count_l, count_l * 100 / table_size); } } }); - logger.info (nano::log::type::ledger, "Finished converting {} blocks", count.load ()); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count.load (), table_size > 0 ? count.load () * 100 / table_size : 100); table_size = store.count (store.tx_begin_read (), tables::pending); logger.info (nano::log::type::ledger, "Step 2 of 7: Converting {} entries from pending table", table_size); @@ -1324,11 +1324,11 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p rocksdb_store->pending.put (rocksdb_transaction, i->first, i->second); if (auto count_l = ++count; count_l % 500000 == 0) { - logger.info (nano::log::type::ledger, "{} entries converted", count_l); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count_l, count_l * 100 / table_size); } } }); - logger.info (nano::log::type::ledger, "Finished converting {} entries", count.load ()); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count.load (), table_size > 0 ? count.load () * 100 / table_size : 100); table_size = store.count (store.tx_begin_read (), tables::confirmation_height); logger.info (nano::log::type::ledger, "Step 3 of 7: Converting {} entries from confirmation_height table", table_size); @@ -1342,11 +1342,11 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p rocksdb_store->confirmation_height.put (rocksdb_transaction, i->first, i->second); if (auto count_l = ++count; count_l % 500000 == 0) { - logger.info (nano::log::type::ledger, "{} entries converted", count_l); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count_l, count_l * 100 / table_size); } } }); - logger.info (nano::log::type::ledger, "Finished converting {} entries", count.load ()); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count.load (), table_size > 0 ? count.load () * 100 / table_size : 100); table_size = store.count (store.tx_begin_read (), tables::accounts); logger.info (nano::log::type::ledger, "Step 4 of 7: Converting {} entries from accounts table", table_size); @@ -1360,11 +1360,11 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p rocksdb_store->account.put (rocksdb_transaction, i->first, i->second); if (auto count_l = ++count; count_l % 500000 == 0) { - logger.info (nano::log::type::ledger, "{} entries converted", count_l); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count_l, count_l * 100 / table_size); } } }); - logger.info (nano::log::type::ledger, "Finished converting {} entries", count.load ()); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count.load (), table_size > 0 ? count.load () * 100 / table_size : 100); table_size = store.count (store.tx_begin_read (), tables::rep_weights); logger.info (nano::log::type::ledger, "Step 5 of 7: Converting {} entries from rep_weights table", table_size); @@ -1378,11 +1378,11 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p rocksdb_store->rep_weight.put (rocksdb_transaction, i->first, i->second.number ()); if (auto count_l = ++count; count_l % 500000 == 0) { - logger.info (nano::log::type::ledger, "{} entries converted", count_l); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count_l, count_l * 100 / table_size); } } }); - logger.info (nano::log::type::ledger, "Finished converting {} entries", count.load ()); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count.load (), table_size > 0 ? count.load () * 100 / table_size : 100); table_size = store.count (store.tx_begin_read (), tables::pruned); logger.info (nano::log::type::ledger, "Step 6 of 7: Converting {} entries from pruned table", table_size); @@ -1396,11 +1396,11 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p rocksdb_store->pruned.put (rocksdb_transaction, i->first); if (auto count_l = ++count; count_l % 500000 == 0) { - logger.info (nano::log::type::ledger, "{} entries converted", count_l); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count_l, count_l * 100 / table_size); } } }); - logger.info (nano::log::type::ledger, "Finished converting {} entries", count.load ()); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count.load (), table_size > 0 ? count.load () * 100 / table_size : 100); table_size = store.count (store.tx_begin_read (), tables::final_votes); logger.info (nano::log::type::ledger, "Step 7 of 7: Converting {} entries from final_votes table", table_size); @@ -1414,11 +1414,11 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p rocksdb_store->final_vote.put (rocksdb_transaction, i->first, i->second); if (auto count_l = ++count; count_l % 500000 == 0) { - logger.info (nano::log::type::ledger, "{} entries converted", count_l); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count_l, count_l * 100 / table_size); } } }); - logger.info (nano::log::type::ledger, "Finished converting {} entries", count.load ()); + logger.info (nano::log::type::ledger, "{} entries converted ({}%)", count.load (), table_size > 0 ? count.load () * 100 / table_size : 100); logger.info (nano::log::type::ledger, "Finalizing migration..."); auto lmdb_transaction (store.tx_begin_read ()); From abb09cd939b816e835b30072b48d11eb495f6ab7 Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Sun, 8 Sep 2024 13:33:12 +0200 Subject: [PATCH 2/2] Verify rep_weight table count --- nano/secure/ledger.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index d3bcbb7dce..daf73eacb1 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -1441,6 +1441,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p error |= store.pruned.count (lmdb_transaction) != rocksdb_store->pruned.count (rocksdb_transaction); error |= store.final_vote.count (lmdb_transaction) != rocksdb_store->final_vote.count (rocksdb_transaction); error |= store.online_weight.count (lmdb_transaction) != rocksdb_store->online_weight.count (rocksdb_transaction); + error |= store.rep_weight.count (lmdb_transaction) != rocksdb_store->rep_weight.count (rocksdb_transaction); error |= store.version.get (lmdb_transaction) != rocksdb_store->version.get (rocksdb_transaction); // For large tables a random key is used instead and makes sure it exists