Skip to content

Commit

Permalink
Rocksdb migration: disk space check and progress output
Browse files Browse the repository at this point in the history
  • Loading branch information
RickiNano committed Jun 13, 2024
1 parent e4d98f3 commit 7a43a35
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nano/node/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
15 changes: 15 additions & 0 deletions nano/secure/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 7a43a35

Please sign in to comment.