Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate_database_lmdb_to_rocksdb improvements #4647

Open
wants to merge 13 commits into
base: develop
Choose a base branch
from

Conversation

RickiNano
Copy link
Contributor

@RickiNano RickiNano commented Jun 13, 2024

The migrate_database_lmdb_to_rocksdb option is running for a very long time with the current ledger size (almost 200 million blocks). On my local machine it took 65 minutes to complete. Nothing is written on screen during this process and users may think the process has stalled.
This PR adds some progress feedback. One update for each of the 7 tables that are migrated.
It also adds a simple disk space check to warn users if they might not have enough space to complete the migration.
The current converted RocksDb database is 73 GB, and the warning is given if the system has less than 75GB available.
The warning is given based on the size of the LMDB database that is being migrated. The final RocksDb size is approximately 65% of the LMDB space.

@pwojcikdev
Copy link
Contributor

This should be using node logger not cout, otherwise logs aren't saved to disk. There are some places in the existing code that are using cout too, but those are leftovers. Also, printing progress every x converted entries would be nice.

@RickiNano
Copy link
Contributor Author

I have been unable to get node logger implemented. I don't think it's important since the migration is a one time process.
I've updated the code with more granular updates to indicate that progress is being made.
Here is the output of a full production lmdb to rocksDb migration:

image

@pwojcikdev
Copy link
Contributor

I have been unable to get node logger implemented. I don't think it's important since the migration is a one time process.

And that's exactly the reason why it should be logged well, in line with production ready code. In case something goes wrong there should be a persistent record.

@RickiNano
Copy link
Contributor Author

@pwojcikdev
I got the Nano logger implemented now.
Instead of outputting dots for each step it is now giving actual numbers to the log.
image

gr0vity-dev pushed a commit to gr0vity-dev/nano-node that referenced this pull request Jul 1, 2024
gr0vity-dev pushed a commit to gr0vity-dev/nano-node that referenced this pull request Jul 2, 2024
gr0vity-dev pushed a commit to gr0vity-dev/nano-node that referenced this pull request Jul 2, 2024
gr0vity-dev pushed a commit to gr0vity-dev/nano-node that referenced this pull request Jul 2, 2024
gr0vity-dev pushed a commit to gr0vity-dev/nano-node that referenced this pull request Jul 2, 2024
@qwahzi qwahzi added this to the V27 milestone Jul 2, 2024
@qwahzi qwahzi added this to In Progress / V27.0 in Nano Roadmap Jul 2, 2024
}

int main (int argc, char * const * argv)
{
nano::set_umask (); // Make sure the process umask is set before any files are created
nano::logger::initialize (nano::log_config::cli_default ());

nano::set_file_descriptor_limit (OPEN_FILE_DESCRIPTORS_LIMIT);
auto const file_descriptor_limit = nano::get_file_descriptor_limit ();
nano::default_logger ().info (nano::log::type::daemon, "File descriptors limit: {}", file_descriptor_limit);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be moved, this won't log anything.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could split setting the file descriptor limit with logging the warning about it being too low, though setting the file descriptor limit was moved here since it was only set when called with "--daemon" before and it needed to be set at least for "--migrate_database_lmdb_to_rocksdb" if not other commands when used with rocksdb when it has many files.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the limit here is not a problem, it's a good place for it. The problem is trying to log when logging is still in CLI mode. CLI commands usually have a very specific output format and to avoid polluting it with node details, only critical errors are logged. The warning probably needs to be logged via cerr, and the "File descriptors limit: {}"... line moved back into the daemon code, so it leaves a trace in log files if we ever need to debug it.

nano::log_config nano::log_config::cli_default ()
{
	log_config config{};
	config.default_level = nano::log::level::critical;
	config.console.colors = false; // to avoid printing warning about cerr and colors
	config.console.to_cerr = true; // Use cerr to avoid interference with CLI output that goes to stdout
	config.file.enable = false;
	return config;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed a commit which should fix the logging. Also, as setting the limit was moved away from daemon class, targets other than cli wallet would no longer set it.

auto rocksdb_store = nano::make_store (logger, data_path_a, nano::dev::constants, false, true, rocksdb_config);

if (!rocksdb_store->init_error ())
{
logger.info (nano::log::type::ledger, "Step 1 of 7: Converting blocks table");
std::atomic<std::size_t> count = 0;
auto refresh_interval = 20ms;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why such a short refresh interval?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In Progress / V27.0
Nano Roadmap
In Progress / V27.0
Development

Successfully merging this pull request may close these issues.

None yet

4 participants