Skip to content

Commit

Permalink
spec_exec: don't use wildcard '_' in QueryError match
Browse files Browse the repository at this point in the history
Since last time, during error refactor I introduced a silent
bug to the code (scylladb#1075),
I'd like to prevent that from happening in the future. This is why
we replace a `_` match with explicit error variants when deciding
if error received from speculative execution should be ignored.

We also enabled the `wildcard_enum_match_arm` clippy lint.
  • Loading branch information
muzarski committed Oct 14, 2024
1 parent a360f7a commit 8dddca1
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions scylla/src/transport/speculative_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,29 @@ impl SpeculativeExecutionPolicy for PercentileSpeculativeExecutionPolicy {
fn can_be_ignored<ResT>(result: &Result<ResT, QueryError>) -> bool {
match result {
Ok(_) => false,
Err(QueryError::BrokenConnection(_)) => true,
Err(QueryError::ConnectionPoolError(_)) => true,
Err(QueryError::TimeoutError) => true,
_ => false,
Err(e) => {
// Do not remove this lint!
// It's there for a reason - we don't want new variants
// automatically fall under `_` pattern when they are introduced.
#[deny(clippy::wildcard_enum_match_arm)]
match e {
QueryError::BrokenConnection(_)
| QueryError::ConnectionPoolError(_)
| QueryError::TimeoutError => true,

QueryError::DbError(_, _)
| QueryError::BadQuery(_)
| QueryError::CqlRequestSerialization(_)
| QueryError::BodyExtensionsParseError(_)
| QueryError::EmptyPlan
| QueryError::CqlResultParseError(_)
| QueryError::CqlErrorParseError(_)
| QueryError::MetadataError(_)
| QueryError::ProtocolError(_)
| QueryError::UnableToAllocStreamId
| QueryError::RequestTimeout(_) => false,
}
}
}
}

Expand Down

0 comments on commit 8dddca1

Please sign in to comment.