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 (#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.
  • Loading branch information
muzarski committed Oct 4, 2024
1 parent f263046 commit e09334f
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions scylla/src/transport/speculative_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,23 @@ 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) => 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 e09334f

Please sign in to comment.