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

[1.0-beta4] Add max-reversible-blocks option #493

Merged
merged 7 commits into from
Aug 8, 2024

Conversation

heifner
Copy link
Member

@heifner heifner commented Aug 7, 2024

New chain_plugin option max-reversible-blocks. Specifies the maximum number of reversible blocks beyond current LIB to allow before the node is gracefully shutdown. The graceful shutdown is provided as a way to prevent out of memory kill by OS. Once consensus is working again the node can be started with a larger max-reversible-blocks value to continue.

  --max-reversible-blocks arg (=3600)   Approximate maximum allowed reversible
                                        blocks before shutdown. Will shut down
                                        if limit reached. Specify 0 to disable.

Resolves #447

@heifner heifner requested review from greg7mdp and linh2931 August 7, 2024 17:53
@heifner heifner added the OCI Work exclusive to OCI team label Aug 7, 2024
@greg7mdp
Copy link
Contributor

greg7mdp commented Aug 7, 2024

I think it might be a good idea to allow the user to disable the check with --max-reversible-blocks 0.

@greg7mdp
Copy link
Contributor

greg7mdp commented Aug 7, 2024

The name is a bit misleading. It is not really max_reversible_blocks, but longest_reversible_branch_allowed.

@heifner
Copy link
Member Author

heifner commented Aug 7, 2024

The name is a bit misleading. It is not really max_reversible_blocks, but longuest_reversible_branch_allowed.

It is not that either. It is max-reversible-blocks-allowed-on-best-branch or max-reversible-blocks for short.

@greg7mdp
Copy link
Contributor

greg7mdp commented Aug 7, 2024

The name is a bit misleading. It is not really max_reversible_blocks, but longuest_reversible_branch_allowed.

It is not that either. It is max-reversible-blocks-allowed-on-best-branch or max-reversible-blocks for short.

Not quite, it is used in create_block_state_i on a block pushed on a branch which may not be the best branch, right?

@heifner
Copy link
Member Author

heifner commented Aug 7, 2024

Not quite, it is used in create_block_state_i on a block pushed on a branch which may not be the best branch, right?

Correct, in that case it could be any branch.

@greg7mdp
Copy link
Contributor

greg7mdp commented Aug 7, 2024

Not quite, it is used in create_block_state_i on a block pushed on a branch which may not be the best branch, right?

Correct, in that case it could be any branch.

So really we cannot create any branch longer than max_reversible_blocks, right? If so, it really is longuest_reversible_branch_allowed.

I feel that max_reversible_blocks implies the total number of blocks in fork_db, which this definitely isn't.

@heifner
Copy link
Member Author

heifner commented Aug 7, 2024

So really we cannot create any branch longer than max_reversible_blocks, right? If so, it really is longuest_reversible_branch_allowed.

I feel that max_reversible_blocks implies the total number of blocks in fork_db, which this definitely isn't.

The description is Approximate maximum allowed reversible blocks. I didn't want to tie down the implementation in case we have reason to change it. Would like to allow this config option to work even if we change to forkdb.size() or fork_db.root()->block_num() + {head or reversible_block_num}

@greg7mdp
Copy link
Contributor

greg7mdp commented Aug 7, 2024

I didn't want to tie down the implementation in case we have reason to change it...

Sounds good, thanks!

@heifner heifner requested review from greg7mdp and linh2931 August 7, 2024 20:41
@heifner
Copy link
Member Author

heifner commented Aug 7, 2024

I didn't want to tie down the implementation in case we have reason to change it...

Discussed with team and decided to tie the implementation to forkdb.size().

@@ -360,7 +360,7 @@ void chain_plugin::set_program_options(options_description& cli, options_descrip
#endif
("enable-account-queries", bpo::value<bool>()->default_value(false), "enable queries to find accounts by various metadata.")
("max-reversible-blocks", bpo::value<uint32_t>()->default_value(config::default_max_reversible_blocks),
"Approximate maximum allowed reversible blocks before shutdown. Will shut down if limit reached.")
"Approximate maximum allowed reversible blocks before shutdown. Will shut down if limit reached. Specify 0 to disable.")
Copy link
Member

Choose a reason for hiding this comment

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

I don't see where you set it to an internal big number to disable if the user configures it to 0.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

@heifner heifner Aug 7, 2024

Choose a reason for hiding this comment

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

Now that I'm not adding the value to reversible_block_num, might be nicer to just set it to std::numeric_limits<uint32_t>::max() if 0.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, but the if > 0 does avoid the mutex if that has any worth. I guess I'll leave it as is.

@heifner heifner merged commit fec00e4 into release/1.0-beta4 Aug 8, 2024
36 checks passed
@heifner heifner deleted the GH-447-term-excessive-blocks branch August 8, 2024 01:17
@ericpassmore
Copy link
Contributor

Note:start
group: PROTOCOL
category: HTTP
summary: Adds new chain_plugin option max-reversible-blocks. Specifies the maximum number of reversible blocks beyond current LIB to allow before the node is gracefully shutdown.
Note:end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCI Work exclusive to OCI team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminate nodeos when reversible blocks exceeds irreversible blocks by excessive amount
4 participants