Skip to content

Commit

Permalink
errors: remove IoError variant from [Query/NS]Error
Browse files Browse the repository at this point in the history
As I mentioned previously, these variants were replaced
by `BrokenConnection` and `ConnectionPoolError` variants.

We can now get rid of the variants that are never constructed.
We also need to remove all usages of these variants
(retry_policy/use_keyspace/speculative_execution).
  • Loading branch information
muzarski committed Sep 19, 2024
1 parent 9ae0077 commit ce0fdca
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 24 deletions.
6 changes: 3 additions & 3 deletions scylla/src/transport/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -785,9 +785,9 @@ pub(crate) fn use_keyspace_result(
match result {
Ok(()) => was_ok = true,
Err(err) => match err {
QueryError::IoError(_)
| QueryError::BrokenConnection(_)
| QueryError::ConnectionPoolError(_) => broken_conn_error = Some(err),
QueryError::BrokenConnection(_) | QueryError::ConnectionPoolError(_) => {
broken_conn_error = Some(err)
}
_ => return Err(err),
},
}
Expand Down
6 changes: 1 addition & 5 deletions scylla/src/transport/downgrading_consistency_retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ impl RetrySession for DowngradingConsistencyRetrySession {
match query_info.error {
// Basic errors - there are some problems on this node
// Retry on a different one if possible
QueryError::IoError(_)
| QueryError::BrokenConnection(_)
QueryError::BrokenConnection(_)
| QueryError::ConnectionPoolError(_)
| QueryError::DbError(DbError::Overloaded, _)
| QueryError::DbError(DbError::ServerError, _)
Expand Down Expand Up @@ -183,8 +182,6 @@ impl RetrySession for DowngradingConsistencyRetrySession {

#[cfg(test)]
mod tests {
use std::{io::ErrorKind, sync::Arc};

use bytes::Bytes;

use crate::test_utils::setup_tracing;
Expand Down Expand Up @@ -334,7 +331,6 @@ mod tests {
BrokenConnectionErrorKind::TooManyOrphanedStreamIds(5).into(),
),
QueryError::ConnectionPoolError(ConnectionPoolError::Initializing),
QueryError::IoError(Arc::new(std::io::Error::new(ErrorKind::Other, "test"))),
];

for &cl in CONSISTENCY_LEVELS {
Expand Down
9 changes: 0 additions & 9 deletions scylla/src/transport/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ pub enum QueryError {
#[error("Failed to deserialize ERROR response: {0}")]
CqlErrorParseError(#[from] CqlErrorParseError),

/// Input/Output error has occurred, connection broken etc.
#[error("IO Error: {0}")]
IoError(Arc<std::io::Error>),

/// Selected node's connection pool is in invalid state.
#[error("No connections in the pool: {0}")]
ConnectionPoolError(#[from] ConnectionPoolError),
Expand Down Expand Up @@ -154,7 +150,6 @@ impl From<QueryError> for NewSessionError {
QueryError::BadQuery(e) => NewSessionError::BadQuery(e),
QueryError::CqlResultParseError(e) => NewSessionError::CqlResultParseError(e),
QueryError::CqlErrorParseError(e) => NewSessionError::CqlErrorParseError(e),
QueryError::IoError(e) => NewSessionError::IoError(e),
QueryError::ConnectionPoolError(e) => NewSessionError::ConnectionPoolError(e),
QueryError::ProtocolError(m) => NewSessionError::ProtocolError(m),
QueryError::InvalidMessage(m) => NewSessionError::InvalidMessage(m),
Expand Down Expand Up @@ -207,10 +202,6 @@ pub enum NewSessionError {
#[error("Failed to deserialize ERROR response: {0}")]
CqlErrorParseError(#[from] CqlErrorParseError),

/// Input/Output error has occurred, connection broken etc.
#[error("IO Error: {0}")]
IoError(Arc<std::io::Error>),

/// Selected node's connection pool is in invalid state.
#[error("No connections in the pool: {0}")]
ConnectionPoolError(#[from] ConnectionPoolError),
Expand Down
1 change: 0 additions & 1 deletion scylla/src/transport/load_balancing/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2855,7 +2855,6 @@ mod latency_awareness {
| QueryError::CqlResultParseError(_)
| QueryError::CqlErrorParseError(_)
| QueryError::InvalidMessage(_)
| QueryError::IoError(_)
| QueryError::ProtocolError(_)
| QueryError::TimeoutError
| QueryError::RequestTimeout(_) => true,
Expand Down
6 changes: 1 addition & 5 deletions scylla/src/transport/retry_policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ impl RetrySession for DefaultRetrySession {
match query_info.error {
// Basic errors - there are some problems on this node
// Retry on a different one if possible
QueryError::IoError(_)
| QueryError::BrokenConnection(_)
QueryError::BrokenConnection(_)
| QueryError::ConnectionPoolError(_)
| QueryError::DbError(DbError::Overloaded, _)
| QueryError::DbError(DbError::ServerError, _)
Expand Down Expand Up @@ -228,8 +227,6 @@ mod tests {
};
use crate::transport::errors::{DbError, WriteType};
use bytes::Bytes;
use std::io::ErrorKind;
use std::sync::Arc;

fn make_query_info(error: &QueryError, is_idempotent: bool) -> QueryInfo<'_> {
QueryInfo {
Expand Down Expand Up @@ -331,7 +328,6 @@ mod tests {
BrokenConnectionErrorKind::TooManyOrphanedStreamIds(5).into(),
),
QueryError::ConnectionPoolError(ConnectionPoolError::Initializing),
QueryError::IoError(Arc::new(std::io::Error::new(ErrorKind::Other, "test"))),
];

for error in idempotent_next_errors {
Expand Down
1 change: 0 additions & 1 deletion scylla/src/transport/speculative_execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ fn can_be_ignored<ResT>(result: &Result<ResT, QueryError>) -> bool {
Ok(_) => false,
Err(QueryError::BrokenConnection(_)) => true,
Err(QueryError::ConnectionPoolError(_)) => true,
Err(QueryError::IoError(_)) => true,
Err(QueryError::TimeoutError) => true,
_ => false,
}
Expand Down

0 comments on commit ce0fdca

Please sign in to comment.