Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,12 @@ revm-precompile = "16.2.0"
revm-primitives = "15.2.0"
rocksdb = "0.21.0"
ruzstd = "0.7.1"
scylla = "0.15.1"
scylla = "1.1.0"
secp256k1 = { version = "0.30.0", default-features = false, features = [
"alloc",
"rand",
"serde",
] }
semver = "1.0.22"
serde = { version = "1.0.197", features = ["derive"] }
serde-name = "0.2.1"
Expand Down
57 changes: 38 additions & 19 deletions linera-views/src/backends/scylla_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ use async_lock::{Semaphore, SemaphoreGuard};
use futures::{future::join_all, FutureExt as _, StreamExt};
use linera_base::ensure;
use scylla::{
batch::BatchStatement,
prepared_statement::PreparedStatement,
statement::batch::BatchType,
transport::errors::{DbError, QueryError},
Session, SessionBuilder,
client::{session::Session, session_builder::SessionBuilder},
deserialize::{DeserializationError, TypeCheckError},
errors::{
DbError, ExecutionError, IntoRowsResultError, NewSessionError, NextPageError, NextRowError,
PagerExecutionError, PrepareError, RequestAttemptError, RequestError, RowsError,
},
statement::{
batch::{BatchStatement, BatchType},
prepared::PreparedStatement,
},
};
use serde::{Deserialize, Serialize};
use thiserror::Error;
Expand Down Expand Up @@ -465,27 +470,27 @@ pub enum ScyllaDbStoreInternalError {

/// A deserialization error in ScyllaDB
#[error(transparent)]
DeserializationError(#[from] scylla::deserialize::DeserializationError),
DeserializationError(#[from] DeserializationError),

/// A row error in ScyllaDB
#[error(transparent)]
RowsError(#[from] scylla::transport::query_result::RowsError),
RowsError(#[from] RowsError),

/// A type error in the accessed data in ScyllaDB
#[error(transparent)]
IntoRowsResultError(#[from] scylla::transport::query_result::IntoRowsResultError),
IntoRowsResultError(#[from] IntoRowsResultError),

/// A type check error in ScyllaDB
#[error(transparent)]
TypeCheckError(#[from] scylla::deserialize::TypeCheckError),
TypeCheckError(#[from] TypeCheckError),

/// A query error in ScyllaDB
#[error(transparent)]
ScyllaDbQueryError(#[from] scylla::transport::errors::QueryError),
PagerExecutionError(#[from] PagerExecutionError),

/// A query error in ScyllaDB
#[error(transparent)]
ScyllaDbNewSessionError(#[from] scylla::transport::errors::NewSessionError),
ScyllaDbNewSessionError(#[from] NewSessionError),

/// Namespace contains forbidden characters
#[error("Namespace contains forbidden characters")]
Expand All @@ -498,6 +503,18 @@ pub enum ScyllaDbStoreInternalError {
/// The batch is too long to be written
#[error("The batch is too long to be written")]
BatchTooLong,

/// A prepare error in ScyllaDB
#[error(transparent)]
PrepareError(#[from] PrepareError),

/// An execution error in ScyllaDB
#[error(transparent)]
ExecutionError(#[from] ExecutionError),

/// A next row error in ScyllaDB
#[error(transparent)]
NextRowError(#[from] NextRowError),
}

impl KeyValueStoreError for ScyllaDbStoreInternalError {
Expand Down Expand Up @@ -689,16 +706,16 @@ impl AdminKeyValueStore for ScyllaDbStoreInternal {
let result = match result {
Ok(result) => result,
Err(error) => {
let invalid_or_not_found = match &error {
QueryError::DbError(db_error, msg) => {
*db_error == DbError::Invalid && msg.as_str() == miss_msg
}
let invalid_or_keyspace_not_found = match &error {
PagerExecutionError::NextPageError(NextPageError::RequestFailure(
RequestError::LastAttemptError(RequestAttemptError::DbError(db_error, msg)),
)) => *db_error == DbError::Invalid && msg.as_str() == miss_msg,
_ => false,
};
if invalid_or_not_found {
if invalid_or_keyspace_not_found {
return Ok(Vec::new());
} else {
return Err(ScyllaDbStoreInternalError::ScyllaDbQueryError(error));
return Err(ScyllaDbStoreInternalError::PagerExecutionError(error));
}
}
};
Expand Down Expand Up @@ -780,7 +797,9 @@ impl AdminKeyValueStore for ScyllaDbStoreInternal {
return Ok(true);
};
let missing_table = match &error {
QueryError::DbError(db_error, msg) => {
PrepareError::AllAttemptsFailed {
first_attempt: RequestAttemptError::DbError(db_error, msg),
} => {
if *db_error != DbError::Invalid {
false
} else {
Expand All @@ -794,7 +813,7 @@ impl AdminKeyValueStore for ScyllaDbStoreInternal {
if missing_table {
Ok(false)
} else {
Err(ScyllaDbStoreInternalError::ScyllaDbQueryError(error))
Err(ScyllaDbStoreInternalError::PrepareError(error))
}
}

Expand Down
Loading