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

Node UUID map initialized from cluster discovery #7204

Merged

Conversation

dlex
Copy link
Contributor

@dlex dlex commented Nov 10, 2022

Cover letter

The node UUID to ID map in members_manager was not initialized until it was populated by cluster joiners. That has allowed for slow seed nodes (ones that miss their oportunity to be founding nodes because of being slow) to also possibly miss the assignment of node_id based on their seed_servers index. That could happen if another node joins the cluster before a slow seed node and grabs the node_id that should have belonged to it.

To prevent that, the node UUID to ID map needs to be initialized at the time of cluster bootstrap phase. This PR introduces

  • advertisement of node UUID at cluster discovery phase via cluster_bootstap_info
  • building of node UUID map upon analysis of cluster_bootstap_info replies from the seeds
  • storage of node UUID map in bootstrap_cluster_cmd
  • initialization of node UUID map in members_manager

Fixes #333

Backport Required

  • not a bug fix
  • issue does not exist in previous branches
  • papercut/not impactful enough to backport
  • v22.2.x
  • v22.1.x
  • v21.11.x

UX changes

  • none

Release notes

  • none

"the cluster will proceed, however the cluster will have less actual "
"seed nodes that expected, and may even fail to bootstrap",
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought neither of these would be true with the changes in this PR

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think those are irrelevant to this PR. There will be less seed nodes because the one with different avertised_rpc_api will never act as a seed node (get_node_index_in_seed_servers() will always return empty). The cluster will fail to bootstrap if the number of misconfigured nodes is at least a half of the total.

Copy link
Contributor

@andrwng andrwng Nov 10, 2022

Choose a reason for hiding this comment

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

will never act as a seed node

Ah good point about a misconfigured majority. It's not really problematic for less than a majority, since as a non-founder the node would just join when a majority comes up.

src/v/cluster/cluster_discovery.cc Outdated Show resolved Hide resolved
src/v/cluster/cluster_discovery.cc Outdated Show resolved Hide resolved
src/v/cluster/cluster_discovery.cc Show resolved Hide resolved
src/v/cluster/controller.cc Outdated Show resolved Hide resolved
src/v/cluster/bootstrap_backend.cc Outdated Show resolved Hide resolved
src/v/cluster/members_manager.h Outdated Show resolved Hide resolved
src/v/cluster/bootstrap_backend.cc Show resolved Hide resolved
Node UUID to ID map is collected from cluster_bootstrap_infos.
Analysis of cluster_bootstrap_infos refactored into a single loop.
Consistency checks extraced into a function. Added a check for node UUID
uniqueness. Added a check for advertised_rpc_api matching seed address.
Cleanup.
Node UUID map is stored to bootstrap_cluster_cmd.
create_cluster() refactored to take cmd_data as an arg.
bootstrap_backend now references to members_manager for that.
@dlex dlex force-pushed the 333_node-uuid-into-cluster-bootstrap-info branch from 1e6600c to e76fcf5 Compare November 10, 2022 20:36
@dlex
Copy link
Contributor Author

dlex commented Nov 10, 2022

force-push: addressed comments, fixed the lack of _node_ids_by_uuid in root driven bootstrap mode which caused unit test failures

Copy link
Contributor

@andrwng andrwng left a comment

Choose a reason for hiding this comment

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

LGTM

// the list of founding brokers and the node_uuid map.
brokers founding_brokers;
founding_brokers.reserve(config_seed_servers.size());
node_ids_by_uuid node_ids;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe call this node_uuid_map or node_id_by_uuid or something? Seems easy to conflate with unique_node_ids.

Comment on lines +23 to +33
// node_ids_by_uuid initialization
// ===============================
// If the node UUID to ID map in `members_manager` were not initialized at
// cluster bootstrap, that would have allowed slow seed nodes (ones that miss
// their oportunity to be founding nodes because of being slow) to also possibly
// miss the assignment of `node_id` based on `seed_servers` index (as expected
// for seed nodes). That could happen if another node joins the cluster before a
// slow seed node and grabs the `node_id` that should have belonged to it.
//
// `bootstrap_backend` references `members_manager` to be able to initialize the
// node UUID to ID map in it.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: IMO kinda odd placement; not sure folks would know to look for this context here. Maybe move this down by L146? or somewhere in the header?

@dlex dlex marked this pull request as ready for review November 11, 2022 00:06
@dlex dlex merged commit 2ea7672 into redpanda-data:dev Nov 11, 2022
@@ -2036,10 +2036,13 @@ struct bootstrap_cluster_cmd_data
const bootstrap_cluster_cmd_data&, const bootstrap_cluster_cmd_data&)
= default;

auto serde_fields() { return std::tie(uuid, bootstrap_user_cred); }
auto serde_fields() {
return std::tie(uuid, bootstrap_user_cred, node_ids_by_uuid);
Copy link
Member

@dotnwat dotnwat Nov 12, 2022

Choose a reason for hiding this comment

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

should there have been a version bump here? @dlex

Copy link
Contributor

Choose a reason for hiding this comment

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

22.3.1 is the first release with this message, so there isn't a compatibility concern. If this PR had landed in 22.3.2 we would've had to.

Copy link
Member

Choose a reason for hiding this comment

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

coo

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

Successfully merging this pull request may close these issues.

redpanda: cluster will not form without a node with an empty seed server list
3 participants