From a9f5e96be4f19339e16ffbc23225285232b910dd Mon Sep 17 00:00:00 2001 From: RickiNano <81099017+RickiNano@users.noreply.github.com> Date: Tue, 18 Jun 2024 18:43:51 +0200 Subject: [PATCH] Fix rocksdb migration (#4645) --- nano/store/rocksdb/rocksdb.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nano/store/rocksdb/rocksdb.cpp b/nano/store/rocksdb/rocksdb.cpp index c804ddeade..d605e742e5 100644 --- a/nano/store/rocksdb/rocksdb.cpp +++ b/nano/store/rocksdb/rocksdb.cpp @@ -288,6 +288,15 @@ void nano::store::rocksdb::component::upgrade_v21_to_v22 (store::write_transacti void nano::store::rocksdb::component::upgrade_v22_to_v23 (store::write_transaction const & transaction_a) { logger.info (nano::log::type::rocksdb, "Upgrading database from v22 to v23..."); + + if (!column_family_exists ("rep_weights")) + { + logger.info (nano::log::type::rocksdb, "Creating table rep_weights"); + ::rocksdb::ColumnFamilyOptions new_cf_options; + ::rocksdb::ColumnFamilyHandle * new_cf_handle; + ::rocksdb::Status status = db->CreateColumnFamily (new_cf_options, "rep_weights", &new_cf_handle); + handles.emplace_back (new_cf_handle); + } auto i{ make_iterator (transaction_a, tables::accounts) }; auto end{ store::iterator (nullptr) }; uint64_t processed_accounts = 0; @@ -309,10 +318,10 @@ void nano::store::rocksdb::component::upgrade_v22_to_v23 (store::write_transacti processed_accounts++; if (processed_accounts % 250000 == 0) { - logger.info (nano::log::type::lmdb, "Processed {} accounts", processed_accounts); + logger.info (nano::log::type::rocksdb, "Processed {} accounts", processed_accounts); } } - logger.info (nano::log::type::lmdb, "Processed {} accounts", processed_accounts); + logger.info (nano::log::type::rocksdb, "Processed {} accounts", processed_accounts); version.put (transaction_a, 23); logger.info (nano::log::type::rocksdb, "Upgrading database from v22 to v23 completed"); }