-
Notifications
You must be signed in to change notification settings - Fork 112
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
errors: protocol error refactor #1080
Conversation
See the following report for details: cargo semver-checks output
|
09bc8ce
to
d75ef64
Compare
Rebased on main |
scylla/src/transport/errors.rs
Outdated
/// A protocol error appeared during cluster metadata fetch. | ||
#[error("Cluster metadata fetch protocol error: {0}")] | ||
Metadata(#[from] MetadataProtocolError), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this variant gets #[from]
but others dont?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I think it makes sense to do it for this variant. However, IMO it's not true for variants such as UnexpectedResponse(CqlResponseKind)
- here, CqlResponseKind
is not an error type itself, it's there only to provide more context. The error is that we received an unexpected response - I don't think From<CqlResponseKind>
impl makes sense here.
92311fc
to
f2f43d9
Compare
v2: addressed review comments Most important change is that I removed |
In the following commits, we will be replacing `QueryError::ProtocolError` variants usages with QueryError::ProtocolErrorTyped. Once every usage of QueryError::ProtocolError is replaced, we will remove this variant and rename ProtocolErrorTyped to ProtocolError. ProtocolErrorTyped is a temporary variant name.
Instead of converting keyspace strings to lowercase (which implies an allocation), we can make use of a comparator that does not allocate additional memory.
Added new error type: UseKeyspaceProtocolError and a corresponding variant to ProtocolError.
Wrapped `SingleRowTypedError` returned during schema version fetch. Previously, we would simply drop this error and provide some custom error messages - which, in my opinion were not really insightful.
Added a variant for nonfinished paging state in response to unpaged query.
Previously, this would be a ProtocolError. However, an empty plan received from LBP does not really represent a protocol violation.
Added an error variant that corresponds to pk extraction error. It indicates that prepared statement's metadata provided by the server is invalid.
f2f43d9
to
1c11070
Compare
v2.1: addressed @Lorak-mmk comments |
Replaced last QueryError::ProtocolError variant usages with QueryError::ProtocolErrorTyped (via From impl).
This type represents an error that occurred during cluster metadata fetch (peers and keyspaces).
From now on, the driver will only expect 'class' and replication factor per dc options for NetworkTopologyStrategy. If some other option is detected, an error is returned.
We removed last usages of this variant in previous commit. We can finally get rid of yet another variant that stringified errors.
1c11070
to
204f911
Compare
ref: #519
QueryError::ProtocolError
In this PR we do a refactor of the
QueryError::ProtocolError
variant, which was represented simply as&'static str
. In this PR, we create a new typeProtocolError
which will represent all posible kinds of protocol errors. We simply replace all occurrences ofQueryError::ProtocolError
with a correspondingProtocolError
variant.QueryError::InvalidMessage
This variant is no longer use after the fixes. Previously, this variant was constructed for some protocol errors due to limitations of the
QueryError::ProtocolError
variant type (&'static str
, whenString
was needed). After introducingProtocolError
type, this is no longer an issue. This variant can be safely removed.Pre-review checklist
[ ] I added relevant tests for new features and bug fixes.[ ] I have adjusted the documentation in./docs/source/
.Fixes:
annotations to PR description.