From e09334fce409e87c15f40e050b2f7edd16f0d22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miko=C5=82aj=20Uzarski?= Date: Fri, 4 Oct 2024 13:46:48 +0200 Subject: [PATCH] spec_exec: don't use wildcard '_' in QueryError match Since last time, during error refactor I introduced a silent bug to the code (https://github.com/scylladb/scylla-rust-driver/pull/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. --- scylla/src/transport/speculative_execution.rs | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/scylla/src/transport/speculative_execution.rs b/scylla/src/transport/speculative_execution.rs index ecc9d02c78..ca7b1d0c71 100644 --- a/scylla/src/transport/speculative_execution.rs +++ b/scylla/src/transport/speculative_execution.rs @@ -85,10 +85,23 @@ impl SpeculativeExecutionPolicy for PercentileSpeculativeExecutionPolicy { fn can_be_ignored(result: &Result) -> 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, + }, } }