-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add support for block log splitting #9184
Changes from 18 commits
e9cfda6
3ac568f
efec3c7
34c81d3
f9937b6
dce3cc3
0745026
dd10241
68ec5ae
ebf48b0
00eb6c9
d15e3b5
d2f8e5b
0ebb3fd
5fb2af4
b069f54
3063759
e2dd458
a674825
ee3a733
c158c7b
3207d7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,7 +150,6 @@ class chain_plugin_impl { | |
|
||
|
||
fc::optional<fork_database> fork_db; | ||
fc::optional<block_log> block_logger; | ||
fc::optional<controller::config> chain_config; | ||
fc::optional<controller> chain; | ||
fc::optional<genesis_state> genesis; | ||
|
@@ -228,6 +227,21 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip | |
cfg.add_options() | ||
("blocks-dir", bpo::value<bfs::path>()->default_value("blocks"), | ||
"the location of the blocks directory (absolute path or relative to application data dir)") | ||
("blocks-log-stride", bpo::value<uint32_t>()->default_value(config::default_blocks_log_stride), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should add here (and also in PR API documentation) something like "When the stride is breached, the current blog log and index will be renamed 'blocks--.log/index' and a new current block log and index will be created with the most recent block. All files following this format will be used to construct an extended block log." |
||
"split the block log file when the head block number is the multiple of the split factor\n" | ||
"When the stride is reached, the current block log and index will be renamed 'blocks-num_begin-num_end.log/index'\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use 'block--.log/index' to make it clearer? (here and in the PR documentation) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sorry, markup removed my text |
||
"and a new current block log and index will be created with the most recent block. All files following\n" | ||
"this format will be used to construct an extended block log.") | ||
("max-retained-block-files", bpo::value<uint16_t>()->default_value(config::default_max_retained_block_files), | ||
"the maximum number of blocks files to retain so that the blocks in those files can be queried.\n" | ||
"When the number is reached, the oldest block file would be move to archive dir or deleted if the archive dir is empty.\n" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "would be moved to archive dir" |
||
"The retained block log files should not be manipulated by users." ) | ||
("blocks-archive-dir", bpo::value<bfs::path>()->default_value(config::default_blocks_archive_dir_name), | ||
"the location of the blocks archive directory (absolute path or relative to blocks dir).\n" | ||
"If the value is empty, blocks files beyond the retained limit will be deleted.\n" | ||
"All files in the archive directory are completely under user's control, i.e. they won't be accessed by nodeos anymore.") | ||
("allow-block-log-auto-fix", bpo::value<bool>()->default_value("false"), | ||
"When the existing block log is inconsistent with the index, allows fixing the block log and index files") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this should add that it will take the highest indexed block, if it is valid, otherwise it will repair the block log and reconstruct the index. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, add the same to the PR description. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
("protocol-features-dir", bpo::value<bfs::path>()->default_value("protocol_features"), | ||
"the location of the protocol_features directory (absolute path or relative to application config dir)") | ||
("checkpoint", bpo::value<vector<string>>()->composing(), "Pairs of [BLOCK_NUM,BLOCK_ID] that should be enforced as checkpoints.") | ||
|
@@ -612,7 +626,7 @@ void | |
chain_plugin::do_hard_replay(const variables_map& options) { | ||
ilog( "Hard replay requested: deleting state database" ); | ||
clear_directory_contents( my->chain_config->state_dir ); | ||
auto backup_dir = block_log::repair_log( my->blocks_dir, options.at( "truncate-at-block" ).as<uint32_t>()); | ||
auto backup_dir = block_log::repair_log( my->blocks_dir, options.at( "truncate-at-block" ).as<uint32_t>(),config::reversible_blocks_dir_name); | ||
if( fc::exists( backup_dir / config::reversible_blocks_dir_name ) || | ||
options.at( "fix-reversible-blocks" ).as<bool>()) { | ||
// Do not try to recover reversible blocks if the directory does not exist, unless the option was explicitly provided. | ||
|
@@ -742,6 +756,10 @@ void chain_plugin::plugin_initialize(const variables_map& options) { | |
my->chain_config->blocks_dir = my->blocks_dir; | ||
my->chain_config->state_dir = app().data_dir() / config::default_state_dir_name; | ||
my->chain_config->read_only = my->readonly; | ||
my->chain_config->blocks_archive_dir = options.at("blocks-archive-dir").as<bfs::path>(); | ||
my->chain_config->blocks_log_stride = options.at("blocks-log-stride").as<uint32_t>(); | ||
my->chain_config->max_retained_block_files = options.at("max-retained-block-files").as<uint16_t>(); | ||
my->chain_config->allow_block_log_auto_fix = options.at("allow-block-log-auto-fix").as<bool>(); | ||
|
||
if (auto resmon_plugin = app().find_plugin<resource_monitor_plugin>()) { | ||
resmon_plugin->monitor_directory(my->chain_config->blocks_dir); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"after they are irreversible"