Skip to content

Commit c5f27dd

Browse files
committed
Simplify checks in abort_repair
1 parent 3eb259f commit c5f27dd

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

upstairs/src/downstairs.rs

+26-18
Original file line numberDiff line numberDiff line change
@@ -2708,33 +2708,36 @@ impl Downstairs {
27082708
/// The live-repair may continue after this point to clean up reserved jobs,
27092709
/// to avoid blocking dependencies, but jobs are replaced with no-ops.
27102710
fn abort_repair(&mut self, up_state: &UpstairsState) {
2711-
assert!(self.clients.iter().any(|c| matches!(
2712-
c.state(),
2713-
DsState::LiveRepair |
2714-
// If connection aborted, and restarted, then the re-negotiation
2715-
// could have won this race, and transitioned the reconnecting
2716-
// downstairs from LiveRepair to Faulted to LiveRepairReady.
2717-
DsState::LiveRepairReady |
2718-
// If just a single IO reported failure, we will fault this
2719-
// downstairs and it won't yet have had a chance to move back
2720-
// around to LiveRepairReady yet.
2721-
DsState::Faulted |
2722-
// It's also possible for a Downstairs to be in the process of
2723-
// stopping, due a fault or disconnection
2724-
DsState::Stopping(..) // XXX should we be more specific here?
2725-
)));
2711+
let mut found_valid_state = false;
27262712
for i in ClientId::iter() {
27272713
match self.clients[i].state() {
27282714
DsState::LiveRepair => {
2715+
found_valid_state = true;
27292716
self.fault_client(
27302717
i,
27312718
up_state,
27322719
ClientFaultReason::FailedLiveRepair,
27332720
);
27342721
}
2735-
DsState::LiveRepairReady => {
2736-
// TODO I don't think this is necessary
2737-
self.skip_all_jobs(i);
2722+
// If connection aborted, and restarted, then the re-negotiation
2723+
// could have won this race, and transitioned the reconnecting
2724+
// downstairs from LiveRepair to Faulted to LiveRepairReady.
2725+
DsState::LiveRepairReady => found_valid_state = true,
2726+
2727+
// If just a single IO reported failure, we will fault this
2728+
// downstairs and it won't yet have had a chance to move back
2729+
// around to LiveRepairReady yet.
2730+
DsState::Faulted => found_valid_state = true,
2731+
2732+
// It's also possible for a Downstairs to be in the process of
2733+
// stopping, due a fault or disconnection
2734+
DsState::Stopping(
2735+
ClientStopReason::Replacing
2736+
| ClientStopReason::Disabled
2737+
| ClientStopReason::Deactivated
2738+
| ClientStopReason::Fault(..),
2739+
) => {
2740+
found_valid_state = true;
27382741
}
27392742
_ => {}
27402743
}
@@ -2744,6 +2747,11 @@ impl Downstairs {
27442747
// always clear it.
27452748
self.clients[i].clear_repair_state();
27462749
}
2750+
assert!(
2751+
found_valid_state,
2752+
"abort_repair called without a valid client state: {:?}",
2753+
self.clients.iter().map(|c| c.state()).collect::<Vec<_>>(),
2754+
);
27472755

27482756
if let Some(repair) = &mut self.repair {
27492757
repair.aborting_repair = true;

0 commit comments

Comments
 (0)