-
Notifications
You must be signed in to change notification settings - Fork 102
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
Return Query Error for non existent DC #825
base: main
Are you sure you want to change the base?
Conversation
scylla/src/transport/session.rs
Outdated
@@ -1653,7 +1653,8 @@ impl Session { | |||
QueryFut: Future<Output = Result<ResT, QueryError>>, | |||
ResT: AllowedRunQueryResTType, | |||
{ | |||
let mut last_error: Option<QueryError> = None; | |||
// set default error as no known found as the query plan returns an empty iterator if there are no nodes in the plan | |||
let mut last_error: Option<QueryError> = Some(QueryError::NoKnownNodeFoundError("Please confirm the supplied datacenters exists".to_string())); |
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.
The query_plan is an iterator that provides a Node, but this iterator can be empty due to the inability to find/pick a node which is mostly caused here.
There could be other reasons why the iterator could be empty, but I can't see any yet
69c0a67
to
c1dd8ec
Compare
c1dd8ec
to
ae013c1
Compare
@Lorak-mmk. I can see that the Cassandra tests are failing on CI, but they work locally for me. Thoughts? |
…d when there are no known nodes found during query plan and avoid ambiguity
ae013c1
to
f860086
Compare
@@ -1666,7 +1666,10 @@ impl Session { | |||
.consistency_set_on_statement | |||
.unwrap_or(execution_profile.consistency); | |||
|
|||
let mut query_plan_is_empty = true; |
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.
Wanted to do a peekable check to ensure the iterator is not empty like:
query_plan.peekable()
but it caused this lifetime error:
error: higher-ranked lifetime error
--> scylla/src/transport/session_test.rs:409:5
|
409 | / tokio::spawn(async move {
410 | | let values = (
411 | | (1_i32, 2_i32, "abc"),
412 | | (),
... |
415 | | session_clone.batch(&batch, values).await.unwrap();
416 | | })
| |______^
|
= note: could not prove `[async block@scylla/src/transport/session_test.rs:409:18: 416:6]: std::marker::Send`
```
So, I just defaulted to doing this more simple check
scylla/src/transport/session_test.rs
Outdated
async fn test_non_existent_dc_return_correct_error() { | ||
let ks = "iot"; | ||
|
||
let host = "127.0.0.1"; |
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.
The tests fail because they run Scylla on different IP. Please take a look at other tests in this file - they use create_new_session_builder()
to get a session builder with correct IP. You can then call
.default_execution_profile_handle(handle)
.build()
.await
.expect("cannot create session");
on resulting builder.
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.
Thanks
scylla/src/transport/session_test.rs
Outdated
|
||
#[tokio::test] | ||
async fn test_non_existent_dc_return_correct_error() { | ||
let ks = "iot"; |
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.
Also, please use unique_keyspace_name();
to prevent future conflicts with other tests. I know that the query is supposed to fail, but if we introduce a regression and it doesn't fail, it may cause other tests to fail, making it harder to understand and fix.
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.
Notice that execute_query
returns None
in case there were no nodes tried. The None
is converted into QueryError::ProtocolError("Empty query plan - driver bug!")
at some point - look those places up by grepping on the error message. I don't like the modifications made to execute_query
because now
- The function never returns
None
, but it hasOption
in its return type, - The new behavior will break speculative execution (look at
speculative_execution.rs
).
I don't think that execute_query
needs to be touched at all, it's just that the error message needs to be changed. You should go over the places where Empty query plan - driver bug!
is returned, change it to the new error variant you introduced and that should be it.
@samuelorji what's the status of this? |
Return query error when there are no known nodes found during query planning
Fixes: #747
Pre-review checklist
./docs/source/
.Fixes:
annotations to PR description.