-
Notifications
You must be signed in to change notification settings - Fork 407
feat: Do not route subnet messages to a cooling down subnet #11230
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
Open
mraszyk
wants to merge
6
commits into
master
Choose a base branch
from
mraszyk/no-subnet-messages-to-cooling-down-subnet
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
35e8496
feat: Do not route subnet messages to a cooling down subnet
mraszyk 58c0efc
chore: Fix comment and simplify tests for subnet output responses
mraszyk ae62a2b
chore: Separate `own_subnet_is_cooling_down` from the line above
mraszyk c2e77f1
test: Cover a cooling down remote destination subnet
mraszyk 161581b
Potential fix for pull request finding
mraszyk b84c239
Automatically fixing code for linting and formatting issues
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -42,8 +42,8 @@ struct StreamBuilderMetrics { | |||||||||||||||||
| pub routed_payload_sizes: Histogram, | ||||||||||||||||||
| /// Misrouted messages currently in streams, by remote subnet. | ||||||||||||||||||
| pub stream_misrouted_messages: IntGaugeVec, | ||||||||||||||||||
| /// Canister output queues skipped because this subnet or their destination | ||||||||||||||||||
| /// subnet was cooling down. | ||||||||||||||||||
| /// Output queues skipped because this subnet or their destination subnet was | ||||||||||||||||||
| /// cooling down. | ||||||||||||||||||
| pub cooling_down_skipped_queues: IntCounter, | ||||||||||||||||||
| /// Critical error for payloads above the maximum supported size. | ||||||||||||||||||
| pub critical_error_payload_too_large: IntCounter, | ||||||||||||||||||
|
|
@@ -132,8 +132,8 @@ impl StreamBuilderMetrics { | |||||||||||||||||
| ); | ||||||||||||||||||
| let cooling_down_skipped_queues = metrics_registry.int_counter( | ||||||||||||||||||
| METRIC_COOLING_DOWN_SKIPPED_QUEUES, | ||||||||||||||||||
| "Canister output queues skipped because this subnet or their destination subnet \ | ||||||||||||||||||
| was cooling down. Counted once per queue per round, so the same queue is counted \ | ||||||||||||||||||
| "Output queues skipped because this subnet or their destination subnet was \ | ||||||||||||||||||
| cooling down. Counted once per queue per round, so the same queue is counted \ | ||||||||||||||||||
| repeatedly for as long as either subnet keeps cooling down.", | ||||||||||||||||||
| ); | ||||||||||||||||||
| let critical_error_payload_too_large = | ||||||||||||||||||
|
|
@@ -454,8 +454,10 @@ impl StreamBuilderImpl { | |||||||||||||||||
| self.route_refunds(&mut state, refund_limit, &network_topology, &mut streams); | ||||||||||||||||||
|
|
||||||||||||||||||
| // No canister can have the subnet's own principal as its canister ID, so this | ||||||||||||||||||
| // identifies the messages taken from the subnet's own output queues. | ||||||||||||||||||
| // identifies the messages taken from the subnet's own output queues. Those are | ||||||||||||||||||
| // only ever responses, as the management canister makes no calls of its own. | ||||||||||||||||||
| let own_subnet_as_canister_id = CanisterId::from(self.subnet_id); | ||||||||||||||||||
|
|
||||||||||||||||||
| let own_subnet_is_cooling_down = network_topology.is_cooling_down(&self.subnet_id); | ||||||||||||||||||
|
|
||||||||||||||||||
| let mut requests_to_reject = Vec::new(); | ||||||||||||||||||
|
|
@@ -474,7 +476,7 @@ impl StreamBuilderImpl { | |||||||||||||||||
| // Cheap to clone, `RequestOrResponse` wraps `Arcs`. | ||||||||||||||||||
| let msg = msg.clone(); | ||||||||||||||||||
|
|
||||||||||||||||||
| let is_from_subnet_queues = msg.sender() == own_subnet_as_canister_id; | ||||||||||||||||||
| let is_subnet_output_response = msg.sender() == own_subnet_as_canister_id; | ||||||||||||||||||
|
|
||||||||||||||||||
| match network_topology.route(msg.receiver().get()) { | ||||||||||||||||||
| // Destination subnet found. | ||||||||||||||||||
|
|
@@ -483,15 +485,28 @@ impl StreamBuilderImpl { | |||||||||||||||||
| let dst_subnet_topology = network_topology.subnets().get(&dst_subnet_id); | ||||||||||||||||||
| let dst_subnet_type = dst_subnet_topology.map(|topology| topology.subnet_type); | ||||||||||||||||||
|
|
||||||||||||||||||
| // No messages from canister output queues are routed while either | ||||||||||||||||||
| // this subnet (the source) or the destination subnet is cooling down; | ||||||||||||||||||
| // not even into the loopback stream. Retain the message (along with | ||||||||||||||||||
| // everything behind it in the same queue) until neither subnet is | ||||||||||||||||||
| // cooling down anymore, rather than rejecting or dropping it. | ||||||||||||||||||
| if !is_from_subnet_queues | ||||||||||||||||||
| && (own_subnet_is_cooling_down | ||||||||||||||||||
| || dst_subnet_topology.is_some_and(|topology| topology.cooling_down)) | ||||||||||||||||||
| { | ||||||||||||||||||
| let dst_subnet_is_cooling_down = | ||||||||||||||||||
| dst_subnet_topology.is_some_and(|topology| topology.cooling_down); | ||||||||||||||||||
|
|
||||||||||||||||||
| // No messages from canister output queues are routed while either this | ||||||||||||||||||
| // subnet (the source) or the destination subnet is cooling down; not | ||||||||||||||||||
| // even into the loopback stream. | ||||||||||||||||||
| // | ||||||||||||||||||
| // The subnet's own output responses are exempt for as long as this | ||||||||||||||||||
| // subnet is cooling down, so that it can still respond to the calls it | ||||||||||||||||||
| // has already accepted; whether or not the destination subnet is cooling | ||||||||||||||||||
| // down, the loopback stream included. They are only held back if this | ||||||||||||||||||
| // subnet is not cooling down but the destination subnet is. | ||||||||||||||||||
|
Comment on lines
+495
to
+499
Contributor
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.
Suggested change
You can optionally add "... deliver responses (before the subnet is deleted) to all ...". |
||||||||||||||||||
| // | ||||||||||||||||||
| // Retain the message (along with everything behind it in the same queue) | ||||||||||||||||||
| // until the subnet that holds it back stops cooling down, rather than | ||||||||||||||||||
| // rejecting or dropping it. | ||||||||||||||||||
| let skip_while_cooling_down = if is_subnet_output_response { | ||||||||||||||||||
| !own_subnet_is_cooling_down && dst_subnet_is_cooling_down | ||||||||||||||||||
| } else { | ||||||||||||||||||
| own_subnet_is_cooling_down || dst_subnet_is_cooling_down | ||||||||||||||||||
| }; | ||||||||||||||||||
| if skip_while_cooling_down { | ||||||||||||||||||
| self.metrics.cooling_down_skipped_queues.inc(); | ||||||||||||||||||
| output_iter.exclude_queue(); | ||||||||||||||||||
| continue; | ||||||||||||||||||
|
|
||||||||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Ultimate nitpicking: You could also say
msg.sender().get() == self.subnet_id.get(). Then you wouldn't need an explicitown_subnet_as_canister_id.And regardless, you should probably move
own_subnet_as_canister_id's comment here, as it's more relevant here.