Skip to content

Commit

Permalink
retry_policy: 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 in retry policy
modules.
  • Loading branch information
muzarski committed Oct 4, 2024
1 parent 204f911 commit 98204a1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 12 additions & 1 deletion scylla/src/transport/downgrading_consistency_retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,18 @@ impl RetrySession for DowngradingConsistencyRetrySession {
// Connection to the contacted node is overloaded, try another one
QueryError::UnableToAllocStreamId => RetryDecision::RetryNextNode(None),
// In all other cases propagate the error to the user
_ => RetryDecision::DontRetry,
QueryError::BadQuery(_)
| QueryError::MetadataError(_)
| QueryError::CqlRequestSerialization(_)
| QueryError::BodyExtensionsParseError(_)
| QueryError::EmptyPlan
| QueryError::CqlResultParseError(_)
| QueryError::CqlErrorParseError(_)
| QueryError::ProtocolError(_)
| QueryError::TimeoutError
| QueryError::RequestTimeout(_)
// Remaining db errors
| QueryError::DbError(_, _) => RetryDecision::DontRetry,
}
}

Expand Down
13 changes: 12 additions & 1 deletion scylla/src/transport/retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,18 @@ impl RetrySession for DefaultRetrySession {
// Connection to the contacted node is overloaded, try another one
QueryError::UnableToAllocStreamId => RetryDecision::RetryNextNode(None),
// In all other cases propagate the error to the user
_ => RetryDecision::DontRetry,
QueryError::BadQuery(_)
| QueryError::MetadataError(_)
| QueryError::CqlRequestSerialization(_)
| QueryError::BodyExtensionsParseError(_)
| QueryError::EmptyPlan
| QueryError::CqlResultParseError(_)
| QueryError::CqlErrorParseError(_)
| QueryError::ProtocolError(_)
| QueryError::TimeoutError
| QueryError::RequestTimeout(_)
// Remaining db errors
| QueryError::DbError(_, _) => RetryDecision::DontRetry,
}
}

Expand Down

0 comments on commit 98204a1

Please sign in to comment.