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

Consolidate DownstairsClient::reinitialize #1549

Merged
merged 5 commits into from
Nov 5, 2024

Conversation

mkeeter
Copy link
Contributor

@mkeeter mkeeter commented Nov 1, 2024

Previously, Downstairs::reinitialize would do the following:

  • Call DownstairsClient::on_missing, which updates the client state
  • Skip jobs (if necessary)
  • Call DownstairsClient::reinitialize, which also updates client state

These used to be separate tasks, but they're now in the same place, so it's silly to have them both.

This PR consolidates all of the logic into DownstairsClient::reinitialize.

@mkeeter mkeeter requested review from jmpesp and leftwo November 1, 2024 19:00
@@ -523,27 +515,19 @@ impl Downstairs {
// Specifically, we want to skip jobs if the only path back online for
// that client goes through live-repair; if that client can come back
// through replay, then the jobs must remain live.
let new_state = self.clients[client_id].state();
if matches!(prev_state, DsState::LiveRepair | DsState::Active)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was impossible to go from ActiveFaulted; in the previous implementation of on_missing, Active always became Offline. Therefore, this branch only fired if the incoming state is LiveRepair.

@mkeeter mkeeter force-pushed the mkeeter/consolidate-reinitialize branch from 57097ed to 67a20d7 Compare November 1, 2024 19:03
@@ -1858,7 +1849,6 @@ impl DownstairsClient {
String::new()
},
);
self.checked_state_transition(up_state, DsState::New);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a drive-by change: the calls to restart_connection below always update the state, so doing it here is superfluous.

// If the upstairs is already active (or trying to go active), then the
// downstairs should automatically call PromoteToActive when it reaches
// the relevant state.
let auto_promote = match self.state {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

auto_promote is a deterministic function of self.state, so we don't need to compute it here (because we're passing &self.state into the function below).

@mkeeter mkeeter force-pushed the mkeeter/consolidate-reinitialize branch from 67a20d7 to 489e0d5 Compare November 1, 2024 19:30
@mkeeter mkeeter force-pushed the mkeeter/consolidate-reinitialize branch from 7c40c94 to a9d7090 Compare November 1, 2024 20:49
@mkeeter mkeeter merged commit a9d614a into main Nov 5, 2024
16 checks passed
@mkeeter mkeeter deleted the mkeeter/consolidate-reinitialize branch November 5, 2024 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants