-
Notifications
You must be signed in to change notification settings - Fork 580
Remove departed ingesters from routing table #6680
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -323,6 +323,18 @@ impl RoutingTable { | |
| } | ||
| entry.seeded_from_cp = true; | ||
| } | ||
|
|
||
| /// Removes a node that left the cluster from every routing entry. | ||
| pub fn remove_node(&mut self, node_id: &NodeId) -> usize { | ||
| let mut num_entries = 0; | ||
|
|
||
| for entry in self.table.values_mut() { | ||
| if entry.nodes.remove(node_id).is_some() { | ||
|
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.
When a Useful? React with 👍 / 👎. |
||
| num_entries += 1; | ||
| } | ||
| } | ||
| num_entries | ||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
|
|
@@ -763,6 +775,35 @@ mod tests { | |
| assert!(entry.nodes.contains_key("node-4")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_remove_node() { | ||
| let mut table = RoutingTable::default(); | ||
| let index_uid = IndexUid::for_test("test-index", 0); | ||
|
|
||
| table.apply_capacity_update( | ||
| NodeId::from_str("node-1"), | ||
| index_uid.clone(), | ||
| "test-source".into(), | ||
| 8, | ||
| 3, | ||
| ); | ||
| table.apply_capacity_update( | ||
| NodeId::from_str("node-2"), | ||
| index_uid, | ||
| "test-source".into(), | ||
| 6, | ||
| 2, | ||
| ); | ||
| assert_eq!(table.remove_node(&NodeId::from_str("node-1")), 1); | ||
|
|
||
| let entry = table | ||
| .table | ||
| .get(&("test-index".to_string(), "test-source".to_string())) | ||
| .unwrap(); | ||
| assert!(!entry.nodes.contains_key("node-1")); | ||
| assert!(entry.nodes.contains_key("node-2")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_classify_az_locality() { | ||
| let table = RoutingTable::new(Some("az-1".to_string())); | ||
|
|
||
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.
When the departed ingester is the only known leader for a source, deleting it here also deletes the only evidence the next
GetOrCreateOpenShardsRequestuses to populateunavailable_leaders. If this router observes the removal before the control plane's ingester pool does, the follow-up CP request is sent with an empty unavailable list, so the CP can return the same stale open shard for the removednode_idand the router re-seeds the route instead of forcing a replacement shard; keeping a tombstone/zero-capacity entry long enough to report the leader unavailable would avoid that propagation race.Useful? React with 👍 / 👎.