-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Add support for block log splitting #9184
Changes from 1 commit
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ namespace eosio { namespace chain { | |
namespace detail { class block_log_impl; } | ||
|
||
/* The block log is an external append only log of the blocks with a header. Blocks should only | ||
* be written to the log after they irreverisble as the log is append only. The log is a doubly | ||
* be written to the log after they irreversible as the log is append only. The log is a doubly | ||
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. "after they are irreversible" |
||
* linked list of blocks. There is a secondary index file of only block positions that enables | ||
* O(1) random access lookup by block number. | ||
* | ||
|
@@ -34,7 +34,8 @@ namespace eosio { namespace chain { | |
|
||
class block_log { | ||
public: | ||
block_log(const fc::path& data_dir, fc::path backup_dir = fc::path(), uint64_t stride=1000, uint16_t max_retained_files=10); | ||
block_log(const fc::path& data_dir, fc::path backup_dir = fc::path(), uint64_t stride=1000, | ||
uint16_t max_retained_files=10, bool allow_block_log_auto_fix=false); | ||
block_log(block_log&& other) = default; | ||
~block_log(); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,13 +228,20 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip | |
("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") | ||
"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." ) | ||
"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.") | ||
"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 log file automatically based on the index") | ||
("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.") | ||
|
@@ -752,6 +759,7 @@ void chain_plugin::plugin_initialize(const variables_map& options) { | |
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); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ class replay_tester : public base_tester { | |
struct restart_from_block_log_test_fixture { | ||
tester chain; | ||
uint32_t cutoff_block_num; | ||
bool allow_block_log_auto_fix = false; | ||
restart_from_block_log_test_fixture() { | ||
chain.create_account(N(replay1)); | ||
chain.produce_blocks(1); | ||
|
@@ -80,7 +81,8 @@ struct restart_from_block_log_test_fixture { | |
} | ||
~restart_from_block_log_test_fixture() { | ||
controller::config copied_config = chain.get_config(); | ||
auto genesis = chain::block_log::extract_genesis_state(chain.get_config().blocks_dir); | ||
copied_config.allow_block_log_auto_fix = this->allow_block_log_auto_fix; | ||
auto genesis = chain::block_log::extract_genesis_state(chain.get_config().blocks_dir); | ||
BOOST_REQUIRE(genesis); | ||
|
||
// remove the state files to make sure we are starting from block log | ||
|
@@ -402,6 +404,7 @@ BOOST_FIXTURE_TEST_CASE(restart_from_block_log_with_incomplete_head,restart_from | |
logfile.open("ab"); | ||
const char random_data[] = "12345678901231876983271649837"; | ||
logfile.write(random_data, sizeof(random_data)); | ||
allow_block_log_auto_fix = true; | ||
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'm confused here, why is this being set at the very end of the test? 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 would think that we should have a test for all paths: truncate index don't set flag and verify block log and index are at the block that block log pointed to, same setup but with flag and verify block log points to block that index pointed to, set flag and have block index point to invalid position (possibly both to far and wrong place in file) and verify that it then matches the block log's block (and index is fixed). |
||
} | ||
|
||
struct blocklog_version_setter { | ||
|
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.
Indentation here is a little wierd.