diff --git a/scylla-cql/src/errors.rs b/scylla-cql/src/errors.rs deleted file mode 100644 index 025addb4d..000000000 --- a/scylla-cql/src/errors.rs +++ /dev/null @@ -1,326 +0,0 @@ -//! This module contains various errors which can be returned by `scylla::Session` - -use crate::frame::protocol_features::ProtocolFeatures; -use crate::Consistency; -use bytes::Bytes; -use thiserror::Error; - -/// An error sent from the database in response to a query -/// as described in the [specification](https://github.com/apache/cassandra/blob/5ed5e84613ef0e9664a774493db7d2604e3596e0/doc/native_protocol_v4.spec#L1029)\ -#[derive(Error, Debug, Clone, PartialEq, Eq)] -pub enum DbError { - /// The submitted query has a syntax error - #[error("The submitted query has a syntax error")] - SyntaxError, - - /// The query is syntactically correct but invalid - #[error("The query is syntactically correct but invalid")] - Invalid, - - /// Attempted to create a keyspace or a table that was already existing - #[error( - "Attempted to create a keyspace or a table that was already existing \ - (keyspace: {keyspace}, table: {table})" - )] - AlreadyExists { - /// Created keyspace name or name of the keyspace in which table was created - keyspace: String, - /// Name of the table created, in case of keyspace creation it's an empty string - table: String, - }, - - /// User defined function failed during execution - #[error( - "User defined function failed during execution \ - (keyspace: {keyspace}, function: {function}, arg_types: {arg_types:?})" - )] - FunctionFailure { - /// Keyspace of the failed function - keyspace: String, - /// Name of the failed function - function: String, - /// Types of arguments passed to the function - arg_types: Vec, - }, - - /// Authentication failed - bad credentials - #[error("Authentication failed - bad credentials")] - AuthenticationError, - - /// The logged user doesn't have the right to perform the query - #[error("The logged user doesn't have the right to perform the query")] - Unauthorized, - - /// The query is invalid because of some configuration issue - #[error("The query is invalid because of some configuration issue")] - ConfigError, - - /// Not enough nodes are alive to satisfy required consistency level - #[error( - "Not enough nodes are alive to satisfy required consistency level \ - (consistency: {consistency}, required: {required}, alive: {alive})" - )] - Unavailable { - /// Consistency level of the query - consistency: Consistency, - /// Number of nodes required to be alive to satisfy required consistency level - required: i32, - /// Found number of active nodes - alive: i32, - }, - - /// The request cannot be processed because the coordinator node is overloaded - #[error("The request cannot be processed because the coordinator node is overloaded")] - Overloaded, - - /// The coordinator node is still bootstrapping - #[error("The coordinator node is still bootstrapping")] - IsBootstrapping, - - /// Error during truncate operation - #[error("Error during truncate operation")] - TruncateError, - - /// Not enough nodes responded to the read request in time to satisfy required consistency level - #[error("Not enough nodes responded to the read request in time to satisfy required consistency level \ - (consistency: {consistency}, received: {received}, required: {required}, data_present: {data_present})")] - ReadTimeout { - /// Consistency level of the query - consistency: Consistency, - /// Number of nodes that responded to the read request - received: i32, - /// Number of nodes required to respond to satisfy required consistency level - required: i32, - /// Replica that was asked for data has responded - data_present: bool, - }, - - /// Not enough nodes responded to the write request in time to satisfy required consistency level - #[error("Not enough nodes responded to the write request in time to satisfy required consistency level \ - (consistency: {consistency}, received: {received}, required: {required}, write_type: {write_type})")] - WriteTimeout { - /// Consistency level of the query - consistency: Consistency, - /// Number of nodes that responded to the write request - received: i32, - /// Number of nodes required to respond to satisfy required consistency level - required: i32, - /// Type of write operation requested - write_type: WriteType, - }, - - /// A non-timeout error during a read request - #[error( - "A non-timeout error during a read request \ - (consistency: {consistency}, received: {received}, required: {required}, \ - numfailures: {numfailures}, data_present: {data_present})" - )] - ReadFailure { - /// Consistency level of the query - consistency: Consistency, - /// Number of nodes that responded to the read request - received: i32, - /// Number of nodes required to respond to satisfy required consistency level - required: i32, - /// Number of nodes that experience a failure while executing the request - numfailures: i32, - /// Replica that was asked for data has responded - data_present: bool, - }, - - /// A non-timeout error during a write request - #[error( - "A non-timeout error during a write request \ - (consistency: {consistency}, received: {received}, required: {required}, \ - numfailures: {numfailures}, write_type: {write_type}" - )] - WriteFailure { - /// Consistency level of the query - consistency: Consistency, - /// Number of nodes that responded to the read request - received: i32, - /// Number of nodes required to respond to satisfy required consistency level - required: i32, - /// Number of nodes that experience a failure while executing the request - numfailures: i32, - /// Type of write operation requested - write_type: WriteType, - }, - - /// Tried to execute a prepared statement that is not prepared. Driver should prepare it again - #[error( - "Tried to execute a prepared statement that is not prepared. Driver should prepare it again" - )] - Unprepared { - /// Statement id of the requested prepared query - statement_id: Bytes, - }, - - /// Internal server error. This indicates a server-side bug - #[error("Internal server error. This indicates a server-side bug")] - ServerError, - - /// Invalid protocol message received from the driver - #[error("Invalid protocol message received from the driver")] - ProtocolError, - - /// Rate limit was exceeded for a partition affected by the request. - /// (Scylla-specific) - /// TODO: Should this have a "Scylla" prefix? - #[error("Rate limit was exceeded for a partition affected by the request")] - RateLimitReached { - /// Type of the operation rejected by rate limiting. - op_type: OperationType, - /// Whether the operation was rate limited on the coordinator or not. - /// Writes rejected on the coordinator are guaranteed not to be applied - /// on any replica. - rejected_by_coordinator: bool, - }, - - /// Other error code not specified in the specification - #[error("Other error not specified in the specification. Error code: {0}")] - Other(i32), -} - -impl DbError { - pub fn code(&self, protocol_features: &ProtocolFeatures) -> i32 { - match self { - DbError::ServerError => 0x0000, - DbError::ProtocolError => 0x000A, - DbError::AuthenticationError => 0x0100, - DbError::Unavailable { - consistency: _, - required: _, - alive: _, - } => 0x1000, - DbError::Overloaded => 0x1001, - DbError::IsBootstrapping => 0x1002, - DbError::TruncateError => 0x1003, - DbError::WriteTimeout { - consistency: _, - received: _, - required: _, - write_type: _, - } => 0x1100, - DbError::ReadTimeout { - consistency: _, - received: _, - required: _, - data_present: _, - } => 0x1200, - DbError::ReadFailure { - consistency: _, - received: _, - required: _, - numfailures: _, - data_present: _, - } => 0x1300, - DbError::FunctionFailure { - keyspace: _, - function: _, - arg_types: _, - } => 0x1400, - DbError::WriteFailure { - consistency: _, - received: _, - required: _, - numfailures: _, - write_type: _, - } => 0x1500, - DbError::SyntaxError => 0x2000, - DbError::Unauthorized => 0x2100, - DbError::Invalid => 0x2200, - DbError::ConfigError => 0x2300, - DbError::AlreadyExists { - keyspace: _, - table: _, - } => 0x2400, - DbError::Unprepared { statement_id: _ } => 0x2500, - DbError::Other(code) => *code, - DbError::RateLimitReached { - op_type: _, - rejected_by_coordinator: _, - } => protocol_features.rate_limit_error.unwrap(), - } - } -} - -/// Type of the operation rejected by rate limiting -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum OperationType { - Read, - Write, - Other(u8), -} - -/// Type of write operation requested -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum WriteType { - /// Non-batched non-counter write - Simple, - /// Logged batch write. If this type is received, it means the batch log has been successfully written - /// (otherwise BatchLog type would be present) - Batch, - /// Unlogged batch. No batch log write has been attempted. - UnloggedBatch, - /// Counter write (batched or not) - Counter, - /// Timeout occurred during the write to the batch log when a logged batch was requested - BatchLog, - /// Timeout occurred during Compare And Set write/update - Cas, - /// Write involves VIEW update and failure to acquire local view(MV) lock for key within timeout - View, - /// Timeout occurred when a cdc_total_space_in_mb is exceeded when doing a write to data tracked by cdc - Cdc, - /// Other type not specified in the specification - Other(String), -} - -impl std::fmt::Display for WriteType { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?}", self) - } -} - -impl From for OperationType { - fn from(operation_type: u8) -> OperationType { - match operation_type { - 0 => OperationType::Read, - 1 => OperationType::Write, - other => OperationType::Other(other), - } - } -} - -impl From<&str> for WriteType { - fn from(write_type_str: &str) -> WriteType { - match write_type_str { - "SIMPLE" => WriteType::Simple, - "BATCH" => WriteType::Batch, - "UNLOGGED_BATCH" => WriteType::UnloggedBatch, - "COUNTER" => WriteType::Counter, - "BATCH_LOG" => WriteType::BatchLog, - "CAS" => WriteType::Cas, - "VIEW" => WriteType::View, - "CDC" => WriteType::Cdc, - _ => WriteType::Other(write_type_str.to_string()), - } - } -} - -impl WriteType { - pub fn as_str(&self) -> &str { - match self { - WriteType::Simple => "SIMPLE", - WriteType::Batch => "BATCH", - WriteType::UnloggedBatch => "UNLOGGED_BATCH", - WriteType::Counter => "COUNTER", - WriteType::BatchLog => "BATCH_LOG", - WriteType::Cas => "CAS", - WriteType::View => "VIEW", - WriteType::Cdc => "CDC", - WriteType::Other(write_type) => write_type.as_str(), - } - } -} diff --git a/scylla-cql/src/frame/response/error.rs b/scylla-cql/src/frame/response/error.rs index 48f453e56..6e1a66c24 100644 --- a/scylla-cql/src/frame/response/error.rs +++ b/scylla-cql/src/frame/response/error.rs @@ -1,9 +1,10 @@ -use crate::errors::{DbError, OperationType, WriteType}; use crate::frame::frame_errors::{CqlErrorParseError, LowLevelDeserializationError}; use crate::frame::protocol_features::ProtocolFeatures; use crate::frame::types; +use crate::Consistency; use byteorder::ReadBytesExt; use bytes::Bytes; +use thiserror::Error; #[derive(Debug, Clone)] pub struct Error { @@ -147,10 +148,329 @@ impl Error { } } +/// An error sent from the database in response to a query +/// as described in the [specification](https://github.com/apache/cassandra/blob/5ed5e84613ef0e9664a774493db7d2604e3596e0/doc/native_protocol_v4.spec#L1029)\ +#[derive(Error, Debug, Clone, PartialEq, Eq)] +pub enum DbError { + /// The submitted query has a syntax error + #[error("The submitted query has a syntax error")] + SyntaxError, + + /// The query is syntactically correct but invalid + #[error("The query is syntactically correct but invalid")] + Invalid, + + /// Attempted to create a keyspace or a table that was already existing + #[error( + "Attempted to create a keyspace or a table that was already existing \ + (keyspace: {keyspace}, table: {table})" + )] + AlreadyExists { + /// Created keyspace name or name of the keyspace in which table was created + keyspace: String, + /// Name of the table created, in case of keyspace creation it's an empty string + table: String, + }, + + /// User defined function failed during execution + #[error( + "User defined function failed during execution \ + (keyspace: {keyspace}, function: {function}, arg_types: {arg_types:?})" + )] + FunctionFailure { + /// Keyspace of the failed function + keyspace: String, + /// Name of the failed function + function: String, + /// Types of arguments passed to the function + arg_types: Vec, + }, + + /// Authentication failed - bad credentials + #[error("Authentication failed - bad credentials")] + AuthenticationError, + + /// The logged user doesn't have the right to perform the query + #[error("The logged user doesn't have the right to perform the query")] + Unauthorized, + + /// The query is invalid because of some configuration issue + #[error("The query is invalid because of some configuration issue")] + ConfigError, + + /// Not enough nodes are alive to satisfy required consistency level + #[error( + "Not enough nodes are alive to satisfy required consistency level \ + (consistency: {consistency}, required: {required}, alive: {alive})" + )] + Unavailable { + /// Consistency level of the query + consistency: Consistency, + /// Number of nodes required to be alive to satisfy required consistency level + required: i32, + /// Found number of active nodes + alive: i32, + }, + + /// The request cannot be processed because the coordinator node is overloaded + #[error("The request cannot be processed because the coordinator node is overloaded")] + Overloaded, + + /// The coordinator node is still bootstrapping + #[error("The coordinator node is still bootstrapping")] + IsBootstrapping, + + /// Error during truncate operation + #[error("Error during truncate operation")] + TruncateError, + + /// Not enough nodes responded to the read request in time to satisfy required consistency level + #[error("Not enough nodes responded to the read request in time to satisfy required consistency level \ + (consistency: {consistency}, received: {received}, required: {required}, data_present: {data_present})")] + ReadTimeout { + /// Consistency level of the query + consistency: Consistency, + /// Number of nodes that responded to the read request + received: i32, + /// Number of nodes required to respond to satisfy required consistency level + required: i32, + /// Replica that was asked for data has responded + data_present: bool, + }, + + /// Not enough nodes responded to the write request in time to satisfy required consistency level + #[error("Not enough nodes responded to the write request in time to satisfy required consistency level \ + (consistency: {consistency}, received: {received}, required: {required}, write_type: {write_type})")] + WriteTimeout { + /// Consistency level of the query + consistency: Consistency, + /// Number of nodes that responded to the write request + received: i32, + /// Number of nodes required to respond to satisfy required consistency level + required: i32, + /// Type of write operation requested + write_type: WriteType, + }, + + /// A non-timeout error during a read request + #[error( + "A non-timeout error during a read request \ + (consistency: {consistency}, received: {received}, required: {required}, \ + numfailures: {numfailures}, data_present: {data_present})" + )] + ReadFailure { + /// Consistency level of the query + consistency: Consistency, + /// Number of nodes that responded to the read request + received: i32, + /// Number of nodes required to respond to satisfy required consistency level + required: i32, + /// Number of nodes that experience a failure while executing the request + numfailures: i32, + /// Replica that was asked for data has responded + data_present: bool, + }, + + /// A non-timeout error during a write request + #[error( + "A non-timeout error during a write request \ + (consistency: {consistency}, received: {received}, required: {required}, \ + numfailures: {numfailures}, write_type: {write_type}" + )] + WriteFailure { + /// Consistency level of the query + consistency: Consistency, + /// Number of nodes that responded to the read request + received: i32, + /// Number of nodes required to respond to satisfy required consistency level + required: i32, + /// Number of nodes that experience a failure while executing the request + numfailures: i32, + /// Type of write operation requested + write_type: WriteType, + }, + + /// Tried to execute a prepared statement that is not prepared. Driver should prepare it again + #[error( + "Tried to execute a prepared statement that is not prepared. Driver should prepare it again" + )] + Unprepared { + /// Statement id of the requested prepared query + statement_id: Bytes, + }, + + /// Internal server error. This indicates a server-side bug + #[error("Internal server error. This indicates a server-side bug")] + ServerError, + + /// Invalid protocol message received from the driver + #[error("Invalid protocol message received from the driver")] + ProtocolError, + + /// Rate limit was exceeded for a partition affected by the request. + /// (Scylla-specific) + /// TODO: Should this have a "Scylla" prefix? + #[error("Rate limit was exceeded for a partition affected by the request")] + RateLimitReached { + /// Type of the operation rejected by rate limiting. + op_type: OperationType, + /// Whether the operation was rate limited on the coordinator or not. + /// Writes rejected on the coordinator are guaranteed not to be applied + /// on any replica. + rejected_by_coordinator: bool, + }, + + /// Other error code not specified in the specification + #[error("Other error not specified in the specification. Error code: {0}")] + Other(i32), +} + +impl DbError { + pub fn code(&self, protocol_features: &ProtocolFeatures) -> i32 { + match self { + DbError::ServerError => 0x0000, + DbError::ProtocolError => 0x000A, + DbError::AuthenticationError => 0x0100, + DbError::Unavailable { + consistency: _, + required: _, + alive: _, + } => 0x1000, + DbError::Overloaded => 0x1001, + DbError::IsBootstrapping => 0x1002, + DbError::TruncateError => 0x1003, + DbError::WriteTimeout { + consistency: _, + received: _, + required: _, + write_type: _, + } => 0x1100, + DbError::ReadTimeout { + consistency: _, + received: _, + required: _, + data_present: _, + } => 0x1200, + DbError::ReadFailure { + consistency: _, + received: _, + required: _, + numfailures: _, + data_present: _, + } => 0x1300, + DbError::FunctionFailure { + keyspace: _, + function: _, + arg_types: _, + } => 0x1400, + DbError::WriteFailure { + consistency: _, + received: _, + required: _, + numfailures: _, + write_type: _, + } => 0x1500, + DbError::SyntaxError => 0x2000, + DbError::Unauthorized => 0x2100, + DbError::Invalid => 0x2200, + DbError::ConfigError => 0x2300, + DbError::AlreadyExists { + keyspace: _, + table: _, + } => 0x2400, + DbError::Unprepared { statement_id: _ } => 0x2500, + DbError::Other(code) => *code, + DbError::RateLimitReached { + op_type: _, + rejected_by_coordinator: _, + } => protocol_features.rate_limit_error.unwrap(), + } + } +} + +/// Type of the operation rejected by rate limiting +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum OperationType { + Read, + Write, + Other(u8), +} + +/// Type of write operation requested +#[derive(Debug, Clone, PartialEq, Eq)] +pub enum WriteType { + /// Non-batched non-counter write + Simple, + /// Logged batch write. If this type is received, it means the batch log has been successfully written + /// (otherwise BatchLog type would be present) + Batch, + /// Unlogged batch. No batch log write has been attempted. + UnloggedBatch, + /// Counter write (batched or not) + Counter, + /// Timeout occurred during the write to the batch log when a logged batch was requested + BatchLog, + /// Timeout occurred during Compare And Set write/update + Cas, + /// Write involves VIEW update and failure to acquire local view(MV) lock for key within timeout + View, + /// Timeout occurred when a cdc_total_space_in_mb is exceeded when doing a write to data tracked by cdc + Cdc, + /// Other type not specified in the specification + Other(String), +} + +impl std::fmt::Display for WriteType { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "{:?}", self) + } +} + +impl From for OperationType { + fn from(operation_type: u8) -> OperationType { + match operation_type { + 0 => OperationType::Read, + 1 => OperationType::Write, + other => OperationType::Other(other), + } + } +} + +impl From<&str> for WriteType { + fn from(write_type_str: &str) -> WriteType { + match write_type_str { + "SIMPLE" => WriteType::Simple, + "BATCH" => WriteType::Batch, + "UNLOGGED_BATCH" => WriteType::UnloggedBatch, + "COUNTER" => WriteType::Counter, + "BATCH_LOG" => WriteType::BatchLog, + "CAS" => WriteType::Cas, + "VIEW" => WriteType::View, + "CDC" => WriteType::Cdc, + _ => WriteType::Other(write_type_str.to_string()), + } + } +} + +impl WriteType { + pub fn as_str(&self) -> &str { + match self { + WriteType::Simple => "SIMPLE", + WriteType::Batch => "BATCH", + WriteType::UnloggedBatch => "UNLOGGED_BATCH", + WriteType::Counter => "COUNTER", + WriteType::BatchLog => "BATCH_LOG", + WriteType::Cas => "CAS", + WriteType::View => "VIEW", + WriteType::Cdc => "CDC", + WriteType::Other(write_type) => write_type.as_str(), + } + } +} + #[cfg(test)] mod tests { - use super::Error; - use crate::errors::{DbError, OperationType, WriteType}; + use super::{DbError, Error, OperationType, WriteType}; use crate::frame::protocol_features::ProtocolFeatures; use crate::Consistency; use bytes::Bytes; diff --git a/scylla-cql/src/lib.rs b/scylla-cql/src/lib.rs index 61d9f345c..036a1b848 100644 --- a/scylla-cql/src/lib.rs +++ b/scylla-cql/src/lib.rs @@ -1,4 +1,3 @@ -pub mod errors; pub mod frame; #[macro_use] pub mod macros { diff --git a/scylla-proxy/src/actions.rs b/scylla-proxy/src/actions.rs index 59c812611..274b2c530 100644 --- a/scylla-proxy/src/actions.rs +++ b/scylla-proxy/src/actions.rs @@ -11,7 +11,7 @@ use crate::{ frame::{FrameOpcode, FrameParams, RequestFrame, RequestOpcode, ResponseFrame, ResponseOpcode}, TargetShard, }; -use scylla_cql::errors::DbError; +use scylla_cql::frame::response::error::DbError; /// Specifies when an associated [Reaction] will be performed. /// Conditions are subject to logic, with `not()`, `and()` and `or()` @@ -410,7 +410,7 @@ impl RequestReaction { pub mod example_db_errors { use bytes::Bytes; use scylla_cql::{ - errors::{DbError, WriteType}, + frame::response::error::{DbError, WriteType}, Consistency, }; diff --git a/scylla-proxy/src/frame.rs b/scylla-proxy/src/frame.rs index fe311c0b0..5cabc0714 100644 --- a/scylla-proxy/src/frame.rs +++ b/scylla-proxy/src/frame.rs @@ -6,7 +6,7 @@ use scylla_cql::frame::protocol_features::ProtocolFeatures; use scylla_cql::frame::request::Request; pub use scylla_cql::frame::request::RequestOpcode; pub use scylla_cql::frame::response::ResponseOpcode; -use scylla_cql::{errors::DbError, frame::types}; +use scylla_cql::frame::{response::error::DbError, types}; use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt}; use tracing::warn; diff --git a/scylla/src/errors.rs b/scylla/src/errors.rs index c2be16cf9..72a178308 100644 --- a/scylla/src/errors.rs +++ b/scylla/src/errors.rs @@ -1,5 +1,9 @@ //! This module contains various errors which can be returned by `scylla::Session` +// Re-export DbError type and types that it depends on +// so they can be found in `scylla::errors`. +pub use scylla_cql::frame::response::error::{DbError, OperationType, WriteType}; + use std::{ error::Error, io::ErrorKind, @@ -8,7 +12,6 @@ use std::{ }; use scylla_cql::{ - errors::DbError, frame::{ frame_errors::{ CqlAuthChallengeParseError, CqlAuthSuccessParseError, CqlAuthenticateParseError, @@ -574,12 +577,9 @@ pub(crate) enum ResponseParseError { #[cfg(test)] mod tests { - use scylla_cql::{ - errors::{DbError, WriteType}, - Consistency, - }; + use scylla_cql::Consistency; - use crate::errors::QueryError; + use crate::errors::{DbError, QueryError, WriteType}; #[test] fn write_type_from_str() { diff --git a/scylla/src/history.rs b/scylla/src/history.rs index 924c6445e..af6cfeeae 100644 --- a/scylla/src/history.rs +++ b/scylla/src/history.rs @@ -455,7 +455,10 @@ mod tests { }; use crate::{ - errors::QueryError, query::Query, retry_policy::RetryDecision, test_utils::setup_tracing, + errors::{DbError, QueryError}, + query::Query, + retry_policy::RetryDecision, + test_utils::setup_tracing, utils::test_utils::unique_keyspace_name, }; @@ -467,7 +470,7 @@ mod tests { use assert_matches::assert_matches; use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, Utc}; use futures::StreamExt; - use scylla_cql::{errors::DbError, Consistency}; + use scylla_cql::Consistency; // Set a single time for all timestamps within StructuredHistory. // HistoryCollector sets the timestamp to current time which changes with each test. diff --git a/scylla/src/transport/connection.rs b/scylla/src/transport/connection.rs index 90849c7b8..671ab9c89 100644 --- a/scylla/src/transport/connection.rs +++ b/scylla/src/transport/connection.rs @@ -32,7 +32,7 @@ pub(crate) use ssl_config::SslConfig; use crate::authentication::AuthenticatorProvider; use crate::errors::{ BadKeyspaceName, BrokenConnectionError, BrokenConnectionErrorKind, ConnectionError, - ConnectionSetupRequestError, ConnectionSetupRequestErrorKind, CqlEventHandlingError, + ConnectionSetupRequestError, ConnectionSetupRequestErrorKind, CqlEventHandlingError, DbError, QueryError, RequestError, ResponseParseError, TranslationError, UserRequestError, }; use scylla_cql::frame::response::authenticate::Authenticate; @@ -46,7 +46,6 @@ use std::{ net::{Ipv4Addr, Ipv6Addr}, }; -use super::errors::DbError; use super::iterator::RowIterator; use super::locator::tablets::{RawTablet, TabletParsingError}; use super::query_result::SingleRowTypedError; diff --git a/scylla/src/transport/downgrading_consistency_retry_policy.rs b/scylla/src/transport/downgrading_consistency_retry_policy.rs index b9cdf56bf..fa1dd7701 100644 --- a/scylla/src/transport/downgrading_consistency_retry_policy.rs +++ b/scylla/src/transport/downgrading_consistency_retry_policy.rs @@ -1,11 +1,8 @@ -use scylla_cql::{ - errors::{DbError, WriteType}, - Consistency, -}; +use scylla_cql::Consistency; use tracing::debug; use crate::{ - errors::QueryError, + errors::{DbError, QueryError, WriteType}, retry_policy::{QueryInfo, RetryDecision, RetryPolicy, RetrySession}, }; diff --git a/scylla/src/transport/load_balancing/default.rs b/scylla/src/transport/load_balancing/default.rs index 9fc21bff3..e9ce93e19 100644 --- a/scylla/src/transport/load_balancing/default.rs +++ b/scylla/src/transport/load_balancing/default.rs @@ -2545,13 +2545,15 @@ mod tests { mod latency_awareness { use futures::{future::RemoteHandle, FutureExt}; use itertools::Either; - use scylla_cql::errors::DbError; use tokio::time::{Duration, Instant}; use tracing::{trace, warn}; use uuid::Uuid; use crate::{ - errors::QueryError, load_balancing::NodeRef, routing::Shard, transport::node::Node, + errors::{DbError, QueryError}, + load_balancing::NodeRef, + routing::Shard, + transport::node::Node, }; use std::{ collections::HashMap, diff --git a/scylla/src/transport/mod.rs b/scylla/src/transport/mod.rs index bf6310d35..6324ca6f9 100644 --- a/scylla/src/transport/mod.rs +++ b/scylla/src/transport/mod.rs @@ -21,7 +21,6 @@ pub mod topology; pub use crate::frame::{Authenticator, Compression}; pub use connection::SelfIdentity; pub use execution_profile::ExecutionProfile; -pub use scylla_cql::errors; pub use scylla_cql::frame::request::query::{PagingState, PagingStateResponse}; #[cfg(test)] diff --git a/scylla/src/transport/retry_policy.rs b/scylla/src/transport/retry_policy.rs index 744d5162f..a02dec65b 100644 --- a/scylla/src/transport/retry_policy.rs +++ b/scylla/src/transport/retry_policy.rs @@ -2,9 +2,8 @@ //! To decide when to retry a query the `Session` can use any object which implements //! the `RetryPolicy` trait -use crate::errors::QueryError; +use crate::errors::{DbError, QueryError, WriteType}; use crate::frame::types::Consistency; -use crate::transport::errors::{DbError, WriteType}; /// Information about a failed query pub struct QueryInfo<'a> { @@ -221,9 +220,9 @@ impl RetrySession for DefaultRetrySession { mod tests { use super::{DefaultRetryPolicy, QueryInfo, RetryDecision, RetryPolicy}; use crate::errors::{BadQuery, QueryError}; + use crate::errors::{DbError, WriteType}; use crate::statement::Consistency; use crate::test_utils::setup_tracing; - use crate::transport::errors::{DbError, WriteType}; use bytes::Bytes; use std::io::ErrorKind; use std::sync::Arc; diff --git a/scylla/src/transport/session_test.rs b/scylla/src/transport/session_test.rs index fcbcc2b02..6aaab500a 100644 --- a/scylla/src/transport/session_test.rs +++ b/scylla/src/transport/session_test.rs @@ -1,6 +1,6 @@ use crate as scylla; use crate::batch::{Batch, BatchStatement}; -use crate::errors::{BadKeyspaceName, BadQuery, QueryError}; +use crate::errors::{BadKeyspaceName, BadQuery, DbError, QueryError}; use crate::frame::response::result::Row; use crate::prepared_statement::PreparedStatement; use crate::query::Query; @@ -10,7 +10,6 @@ use crate::statement::Consistency; use crate::test_utils::{scylla_supports_tablets, setup_tracing}; use crate::tracing::TracingInfo; use crate::transport::cluster::Datacenter; -use crate::transport::errors::DbError; use crate::transport::partitioner::{ calculate_token_for_partition_key, Murmur3Partitioner, Partitioner, PartitionerName, }; @@ -2527,7 +2526,7 @@ async fn test_rate_limit_exceeded_exception() { } } - use scylla_cql::errors::OperationType; + use crate::errors::OperationType; match maybe_err.expect("Rate limit error didn't occur") { QueryError::DbError(DbError::RateLimitReached { op_type, .. }, _) => { diff --git a/scylla/src/transport/topology.rs b/scylla/src/transport/topology.rs index e95c022dc..c578ee580 100644 --- a/scylla/src/transport/topology.rs +++ b/scylla/src/transport/topology.rs @@ -1,10 +1,9 @@ -use crate::errors::{NewSessionError, QueryError}; +use crate::errors::{DbError, NewSessionError, QueryError}; use crate::frame::response::event::Event; use crate::routing::Token; use crate::statement::query::Query; use crate::transport::connection::{Connection, ConnectionConfig}; use crate::transport::connection_pool::{NodeConnectionPool, PoolConfig, PoolSize}; -use crate::transport::errors::DbError; use crate::transport::host_filter::HostFilter; use crate::transport::node::resolve_contact_points; use crate::utils::parse::{ParseErrorCause, ParseResult, ParserState};