From 7a43a352fcc225af7d5f61cdfc420d958c511aff Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Thu, 13 Jun 2024 11:29:14 +0200 Subject: [PATCH] Rocksdb migration: disk space check and progress output --- nano/node/cli.cpp | 3 ++- nano/secure/ledger.cpp | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/nano/node/cli.cpp b/nano/node/cli.cpp index 2e1e4df4a4..106689a89d 100644 --- a/nano/node/cli.cpp +++ b/nano/node/cli.cpp @@ -493,7 +493,8 @@ std::error_code nano::handle_node_options (boost::program_options::variables_map if (!error) { - std::cout << "Migration completed, after confirming it is correct the data.ldb file can be deleted if no longer required" << std::endl; + std::cout << "Migration completed. Make sure to enable RocksDb in the config file under [node.rocksdb]" << std::endl; + std::cout << "After confirming correct node operation, the data.ldb file can be deleted if no longer required" << std::endl; } else { diff --git a/nano/secure/ledger.cpp b/nano/secure/ledger.cpp index 481be0181e..1feb833b2f 100644 --- a/nano/secure/ledger.cpp +++ b/nano/secure/ledger.cpp @@ -1218,6 +1218,14 @@ uint64_t nano::ledger::pruning_action (secure::write_transaction & transaction_a // A precondition is that the store is an LMDB store bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_path_a) const { + std::filesystem::space_info si = std::filesystem::space (data_path_a); + + const uintmax_t required_space = 75ull * 1024 * 1024 * 1024; // 75 GB + if (si.available < required_space) + { + std::cout << "Warning. You may not have enough available disk space. An estimated 75 GB of free space is required" << std::endl; + } + boost::system::error_code error_chmod; nano::set_secure_perm_directory (data_path_a, error_chmod); auto rockdb_data_path = data_path_a / "rocksdb"; @@ -1233,6 +1241,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p if (!rocksdb_store->init_error ()) { + std::cout << "Step 1 of 7: Converting blocks table..." << std::endl; store.block.for_each_par ( [&rocksdb_store] (store::read_transaction const & /*unused*/, auto i, auto n) { for (; i != n; ++i) @@ -1249,6 +1258,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p } }); + std::cout << "Step 2 of 7: Converting pending table..." << std::endl; store.pending.for_each_par ( [&rocksdb_store] (store::read_transaction const & /*unused*/, auto i, auto n) { for (; i != n; ++i) @@ -1258,6 +1268,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p } }); + std::cout << "Step 3 of 7: Converting confirmation_height table..." << std::endl; store.confirmation_height.for_each_par ( [&rocksdb_store] (store::read_transaction const & /*unused*/, auto i, auto n) { for (; i != n; ++i) @@ -1267,6 +1278,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p } }); + std::cout << "Step 4 of 7: Converting accounts height table..." << std::endl; store.account.for_each_par ( [&rocksdb_store] (store::read_transaction const & /*unused*/, auto i, auto n) { for (; i != n; ++i) @@ -1276,6 +1288,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p } }); + std::cout << "Step 5 of 7: Converting rep_weights table..." << std::endl; store.rep_weight.for_each_par ( [&rocksdb_store] (store::read_transaction const & /*unused*/, auto i, auto n) { for (; i != n; ++i) @@ -1285,6 +1298,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p } }); + std::cout << "Step 6 of 7: Converting pruned table..." << std::endl; store.pruned.for_each_par ( [&rocksdb_store] (store::read_transaction const & /*unused*/, auto i, auto n) { for (; i != n; ++i) @@ -1294,6 +1308,7 @@ bool nano::ledger::migrate_lmdb_to_rocksdb (std::filesystem::path const & data_p } }); + std::cout << "Step 7 of 7: Converting final_votes table..." << std::endl; store.final_vote.for_each_par ( [&rocksdb_store] (store::read_transaction const & /*unused*/, auto i, auto n) { for (; i != n; ++i)