@@ -2854,27 +2854,65 @@ mod latency_awareness {
28542854 }
28552855
28562856 pub ( crate ) fn reliable_latency_measure ( error : & RequestAttemptError ) -> bool {
2857+ // Do not remove this lint!
2858+ // It's there for a reason - we don't want new variants
2859+ // automatically fall under `_` pattern when they are introduced.
2860+ #[ deny( clippy:: wildcard_enum_match_arm) ]
28572861 match error {
2858- // "fast" errors, i.e. ones that are returned quickly after the query begins
2862+ // "fast" errors, i.e. ones that appeared on driver side, before sending the request
28592863 RequestAttemptError :: CqlRequestSerialization ( _)
28602864 | RequestAttemptError :: BrokenConnectionError ( _)
28612865 | RequestAttemptError :: UnableToAllocStreamId
2862- | RequestAttemptError :: DbError ( DbError :: IsBootstrapping , _)
2863- | RequestAttemptError :: DbError ( DbError :: Unavailable { .. } , _)
2864- | RequestAttemptError :: DbError ( DbError :: Unprepared { .. } , _)
2865- | RequestAttemptError :: DbError ( DbError :: Overloaded , _)
2866- | RequestAttemptError :: DbError ( DbError :: RateLimitReached { .. } , _)
28672866 | RequestAttemptError :: SerializationError ( _) => false ,
28682867
28692868 // "slow" errors, i.e. ones that are returned after considerable time of query being run
2870- RequestAttemptError :: DbError ( _, _)
2871- | RequestAttemptError :: CqlResultParseError ( _)
2869+ RequestAttemptError :: CqlResultParseError ( _)
28722870 | RequestAttemptError :: CqlErrorParseError ( _)
28732871 | RequestAttemptError :: BodyExtensionsParseError ( _)
28742872 | RequestAttemptError :: RepreparedIdChanged { .. }
28752873 | RequestAttemptError :: RepreparedIdMissingInBatch
28762874 | RequestAttemptError :: UnexpectedResponse ( _)
28772875 | RequestAttemptError :: NonfinishedPagingState => true ,
2876+
2877+ // handle db errors
2878+ RequestAttemptError :: DbError ( db_error, _) => {
2879+ // Do not remove this lint!
2880+ // It's there for a reason - we don't want new variants
2881+ // automatically fall under `_` pattern when they are introduced.
2882+ #[ deny( clippy:: wildcard_enum_match_arm) ]
2883+ match db_error {
2884+ // An errors that appeared on server side, but did not require selected node
2885+ // to contact other nodes (i.e. fast server side errors).
2886+ DbError :: IsBootstrapping
2887+ | DbError :: Unavailable { .. }
2888+ | DbError :: Unprepared { .. }
2889+ | DbError :: Overloaded
2890+ | DbError :: RateLimitReached { .. } => false ,
2891+
2892+ // Rest of server side errors that take considerable amount of time to be returned
2893+ DbError :: SyntaxError
2894+ | DbError :: Invalid
2895+ | DbError :: AlreadyExists { .. }
2896+ | DbError :: FunctionFailure { .. }
2897+ | DbError :: AuthenticationError
2898+ | DbError :: TruncateError
2899+ | DbError :: ReadTimeout { .. }
2900+ | DbError :: WriteTimeout { .. }
2901+ | DbError :: ReadFailure { .. }
2902+ | DbError :: WriteFailure { .. }
2903+ | DbError :: ServerError
2904+ | DbError :: ProtocolError
2905+ | DbError :: Unauthorized
2906+ | DbError :: ConfigError
2907+ | DbError :: Other ( _) => true ,
2908+
2909+ // Driver may be used with newer version of scylla-cql, which may define additional error variants.
2910+ // It is better to not include unknown errors in latency measure.
2911+ // `wildcard_enum_match_arm will` will still trigger if we add new variants to DbError,
2912+ // so there is no risk of forgetting to update this match.
2913+ _ => false ,
2914+ }
2915+ }
28782916 }
28792917 }
28802918 }
0 commit comments