Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump rust-driver to 0.15 (with eager deserialization) #206

Merged
merged 5 commits into from
Nov 26, 2024

Conversation

muzarski
Copy link
Collaborator

@muzarski muzarski commented Nov 21, 2024

First 4 commits are a bunch of preparations, to reduce the noise during the commit that actually bumps the version.

One of them fixes most of the occurrences of #177. There are still a few places to be addressed, that are non error related.

Bump to 0.15 commit

CassResult was refactored yet again.

Now, we clearly distinguish betwen Rows and non-Rows result. CassResultKind and CassRowsResult are introduced. CassRowsResult holds information about the (for now, eagerly deserialized) rows and metadata. The usages of CassResult are adjusted throughout the codebase.

CassErrorResult was transformed to an enum:

  • query error - an error that occurred during query execution (before rows deserialization)
  • metadata deserialization error - happens during conversion from QueryResult
    to QueryRowsResult
  • deserialization error - happens during eager rows deserialization.

CassResult construction logic was adjusted to new QueryResult.

As mentioned above, some errors can occur during conversion, thus CassResult::from_result_payload returns a StdResult now. For now, we eagerly deserialize the rows. This is equivalent to the version before this PR.

Pre-review checklist

  • I have split my patch into logically separate commits.
  • All commit messages clearly explain what they change and why.
  • PR description sums up the changes and reasons why they should be introduced.
  • [ ] I have implemented Rust unit tests for the features/changes introduced.
  • [ ] I have enabled appropriate tests in .github/workflows/build.yml in gtest_filter.
  • [ ] I have enabled appropriate tests in .github/workflows/cassandra.yml in gtest_filter.

Once we bump to 0.15, the error can occur during the conversion to
QueryRowsResult. The returned error is not a QueryError, but a standalone
type. This is why, we need to extend our `CassErrorResult` so it's an
enum over possible error types returned during query execution and conversions.

thiserror crate will come in handy, when defining such error type. It allows
to quickly generate `From` implementations for corresponding variants
and most importantly, it helps generating `std::fmt::Display` implementation.
Changing it to enum right now, to reduce the noise
during the commit that actually bumps the version.
@muzarski muzarski marked this pull request as draft November 21, 2024 15:37
@muzarski muzarski self-assigned this Nov 21, 2024
@muzarski muzarski marked this pull request as ready for review November 21, 2024 16:14
@muzarski muzarski requested a review from Lorak-mmk November 21, 2024 16:14
@muzarski muzarski changed the title bump 0.15 bump rust-driver to 0.15 (with eager deserialization) Nov 21, 2024
@muzarski muzarski added this to the 0.3 milestone Nov 21, 2024
@roydahan
Copy link
Collaborator

@Lorak-mmk / @wprzytula your prompt review is greatly appreciated .

@roydahan roydahan requested a review from wprzytula November 25, 2024 12:48
Comment on lines +86 to 87
)) => CassConsistency::from(*consistency),
_ => CassConsistency::CASS_CONSISTENCY_UNKNOWN,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe that we should avoid this wildcard here for the same reasons as scylladb/scylla-rust-driver#1083. This is probably out of scope of this PR, though.

scylla-rust-wrapper/src/query_result.rs Show resolved Hide resolved
Comment on lines 12 to 15
[dependencies]
scylla = { git = "https://github.com/scylladb/scylla-rust-driver.git", rev = "64b4afcd", features = [
scylla = { git = "https://github.com/scylladb/scylla-rust-driver.git", rev = "v0.15.0", features = [
"ssl",
] }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be more idiomatic to use the pinned 0.15 version from crates.io? I.e., =0.15 selector.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, it would. The problem is that it does not work...

scylla and scylla-proxy need to point to the same commit id. Otherwise, we get following error thrown by cargo check --tests:

cargo check --tests
    Checking scylla-cpp-driver-rust v0.2.0 (/home/mikolajuzarski/proj/cpp-rust-driver/scylla-rust-wrapper)
error[E0308]: mismatched types
    --> src/session.rs:1026:51
     |
1026 |                   RequestReaction::forge_with_error(DbError:...
     |  _________________---------------------------------_^
     | |                 |
     | |                 arguments to this function are incorrect
1027 | |                     consistency: Consistency::All,
1028 | |                     received: 1,
1029 | |                     required: 1,
1030 | |                     data_present: false,
1031 | |                 }),
     | |_________________^ expected `DbError`, found a different `DbError`
     |
     = note: `DbError` and `DbError` have similar names, but are actually distinct types
note: `DbError` is defined in crate `scylla_cql`
    --> /home/mikolajuzarski/.cargo/registry/src/index.crates.io-6f17d22bba15001f/scylla-cql-0.4.0/src/frame/response/error.rs:154:1
     |
154  | pub enum DbError {
     | ^^^^^^^^^^^^^^^^
note: `DbError` is defined in crate `scylla_cql`
    --> /home/mikolajuzarski/.cargo/git/checkouts/scylla-rust-driver-8578d68f45edd77e/f59908c/scylla-cql/src/frame/response/error.rs:154:1
     |
154  | pub enum DbError {
     | ^^^^^^^^^^^^^^^^
     = note: perhaps two different versions of crate `scylla_cql` are being used?
note: associated function defined here
    --> /home/mikolajuzarski/.cargo/git/checkouts/scylla-rust-driver-8578d68f45edd77e/f59908c/scylla-proxy/src/actions.rs:369:12
     |
369  |     pub fn forge_with_error(error: DbError) -> Self {
     |            ^^^^^^^^^^^^^^^^

For more information about this error, try `rustc --explain E0308`.
error: could not compile `scylla-cpp-driver-rust` (lib test) due to 1 previous error

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's enough to convince me. Let's leave this as-is.

scylla-rust-wrapper/src/cass_error.rs Show resolved Hide resolved
The logic will become much more complex once we bump to 0.15.
It introduces additional nesting, thus I prefer to extract it to separate
functions (since cass_session_execute is already complex enough).

I also moved the necessary utility functions to query_result module.
1. CassResult was refactored yet again.
Now, we clearly distinguish betwen Rows and non-Rows
result. `CassResultKind` and `CassRowsResult` are
introduced. `CassRowsResult` holds information about
the (for now, eagerly deserialized) rows and metadata.
The usages of `CassResult` are adjusted throughout the codebase.

2. CassErrorResult was extended by two variants:
- metadata deserialization error - happens during conversion from QueryResult
  to QueryRowsResult
- deserialization error - happens during eager rows deserialization.

3. CassResult construction logic was adjusted to new QueryResult.
As mentioned above, some errors can occur during conversion, thus
`CassResult::from_result_payload` returns a StdResult now.
For now, we eagerly deserialize the rows. This is equivalent to the
version before this PR.
@muzarski
Copy link
Collaborator Author

v1.1.1 addressed @wprzytula comments, and opened an issue in rust-driver, as pointed out by @Lorak-mmk

@muzarski muzarski requested a review from wprzytula November 26, 2024 09:35
@muzarski muzarski merged commit 7e044a8 into scylladb:master Nov 26, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants