Skip to content

Commit

Permalink
c/members_table: include members table version in the snapshot
Browse files Browse the repository at this point in the history
Members table version is updated only when cluster membership is
updated. The version must be included in the snapshot as it not always
equal to the snapshot last applied offset.

This PR makes the `members_table::version` consistent across the nodes
even if controller snapshot was applied. The version is exposed to end
users in `/v1/brokers/cluster_view` endpoint.

Fixes: CORE-6783

Signed-off-by: Michał Maślanka <[email protected]>
  • Loading branch information
mmaslankaprv committed Aug 28, 2024
1 parent 7086631 commit d496741
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/v/cluster/controller_snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ struct features_t

struct members_t
: public serde::
envelope<members_t, serde::version<1>, serde::compat_version<0>> {
envelope<members_t, serde::version<2>, serde::compat_version<0>> {
struct node_t
: serde::envelope<node_t, serde::version<0>, serde::compat_version<0>> {
model::broker broker;
Expand Down Expand Up @@ -86,6 +86,9 @@ struct members_t
absl::node_hash_map<model::node_id, update_t> in_progress_updates;

model::offset first_node_operation_command_offset;
// revision of metadata table (offset of last applied cluster member
// command)
model::revision_id version{};

friend bool operator==(const members_t&, const members_t&) = default;

Expand All @@ -97,7 +100,8 @@ struct members_t
removed_nodes,
removed_nodes_still_in_raft0,
in_progress_updates,
first_node_operation_command_offset);
first_node_operation_command_offset,
version);
}
};

Expand Down
9 changes: 7 additions & 2 deletions src/v/cluster/members_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,19 @@ void members_table::fill_snapshot(controller_snapshot& controller_snap) {
controller_snapshot_parts::members_t::node_t{
.broker = md.broker, .state = md.state});
}
snap.version = _version;
}

void members_table::apply_snapshot(
model::offset snap_offset, const controller_snapshot& controller_snap) {
_version = model::revision_id(snap_offset);

const auto& snap = controller_snap.members;

// if version is present in snapshot use it, otherwise fallback to old
// behavior
_version = snap.version != model::revision_id{}
? snap.version
: model::revision_id(snap_offset);

// update the list of brokers

cache_t old_nodes;
Expand Down

0 comments on commit d496741

Please sign in to comment.