Skip to content

Commit

Permalink
Cleaner ConnectionMode handling during replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Dec 9, 2024
1 parent 354277e commit 860cbfe
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions upstairs/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,7 @@ impl DownstairsClient {
panic!("invalid state {:?}", self.state);
};
assert_eq!(*state, NegotiationState::WaitQuorum);
assert!(matches!(
mode,
ConnectionMode::New | ConnectionMode::Replaced
));
assert!(matches!(mode, ConnectionMode::New));
*state = NegotiationState::Reconcile;
}

Expand Down Expand Up @@ -570,11 +567,17 @@ impl DownstairsClient {
ConnectionMode::New
}

// Deliberate Downstairs replacement connects using live-repair,
// with a flag that allows for the address to change
DsState::Stopping(ClientStopReason::Replacing) => {
ConnectionMode::Replaced
}
DsState::Stopping(ClientStopReason::Replacing) => match up_state {
// If we haven't activated yet, then start from New
UpstairsState::GoActive(..) | UpstairsState::Initializing => {
ConnectionMode::New
}
// Otherwise, use live-repair; `ConnectionMode::Replaced`
// indicates that the address is allowed to change.
UpstairsState::Active | UpstairsState::Deactivating { .. } => {
ConnectionMode::Replaced
}
},
};
let new_state = DsState::Connecting {
mode: new_mode,
Expand Down Expand Up @@ -755,7 +758,7 @@ impl DownstairsClient {
match &mut self.state {
DsState::Connecting {
state: NegotiationState::Start { auto_promote },
mode: ConnectionMode::New | ConnectionMode::Replaced,
mode: ConnectionMode::New,
} => {
if *auto_promote {
panic!("called set_active_request while already waiting")
Expand All @@ -769,7 +772,7 @@ impl DownstairsClient {
}
DsState::Connecting {
state: NegotiationState::WaitActive,
mode: ConnectionMode::New | ConnectionMode::Replaced,
mode: ConnectionMode::New,
} => {
info!(
self.log,
Expand Down

0 comments on commit 860cbfe

Please sign in to comment.