Skip to content

Commit b249353

Browse files
committed
errors: add RequestTimeout variant to RequestError
RequestError will be passed to HistoryListener when the request either fails or times out.
1 parent 55e12ac commit b249353

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

scylla/src/errors.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,13 @@ pub enum RequestError {
904904
#[error("No connections in the pool: {0}")]
905905
ConnectionPoolError(#[from] ConnectionPoolError),
906906

907+
/// Failed to run a request within a provided client timeout.
908+
#[error(
909+
"Request execution exceeded a client timeout of {}ms",
910+
std::time::Duration::as_millis(.0)
911+
)]
912+
RequestTimeout(std::time::Duration),
913+
907914
/// Failed to execute request.
908915
#[error(transparent)]
909916
LastAttemptError(#[from] RequestAttemptError),
@@ -914,6 +921,7 @@ impl RequestError {
914921
match self {
915922
RequestError::EmptyPlan => QueryError::EmptyPlan,
916923
RequestError::ConnectionPoolError(e) => e.into(),
924+
RequestError::RequestTimeout(dur) => QueryError::RequestTimeout(dur),
917925
RequestError::LastAttemptError(e) => e.into_query_error(),
918926
}
919927
}

scylla/src/policies/speculative_execution.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ fn can_be_ignored<ResT>(result: &Result<ResT, RequestError>) -> bool {
9797
// in the future, it should not be ignored.
9898
RequestError::EmptyPlan => false,
9999

100+
// Request execution timed out.
101+
RequestError::RequestTimeout(_) => false,
102+
100103
// Can try on another node.
101104
RequestError::ConnectionPoolError { .. } => true,
102105

0 commit comments

Comments
 (0)