-
Notifications
You must be signed in to change notification settings - Fork 22
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
CNDB-12905: Allow usage of ReadQuery#execute rather than only executeInternal in CQL utests #1564
base: main
Are you sure you want to change the base?
Conversation
Checklist before you submit for review
|
979aba7
to
d5bb70f
Compare
There are lots of failures on CI. Most will need to adapt the tests a bit, but I'll also check if the new test execution has caught some real bug. |
Mmh, the failures of |
d5bb70f
to
38bdb05
Compare
6a9c88e
to
78dff15
Compare
@@ -516,19 +516,28 @@ public static UntypedResultSet execute(String query, ConsistencyLevel cl, Object | |||
public static UntypedResultSet execute(String query, ConsistencyLevel cl, QueryState state, Object... values) | |||
throws RequestExecutionException | |||
{ | |||
try |
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.
I have removed the try-catch block because the only caller of this method is SystemDistributedKeyspace#viewStatus
, who simply swallows the exception making this wrapping of RequestValidationException
no-op.
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.
who simply swallows the exception making this wrapping of RequestValidationException no-op
Could this be an actual bug?
Also, it seems Sonar complains about test coverage in this area.
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.
I don't know, how do you think this could fail?
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.
It seems parseAndPrepare
also throws that exception, and it is called by this method.
It seems that parseStatement
(called by parseAndPrepare
) is throwing SyntaxException
that extends the RequestValidationException
.
Interesting history - this execute
method was added with the re-write of the storage engine. The method did not have any callers and the execute
method implementations were throwing that exception. They stopped throwing it in CASSANDRA-13426 so I guess that was left over.
I haven't written particular tests to verify what is going on, just looking around the code. Shall we leave the cleaning for follow-up ticket?
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.
Yes, the generic try-catch block in that variant of execute looks like a reminder of the original implementation. The method is only used by SystemDistributedKeyspace#viewStatus
, which shallows the exception because it's only interested in collecting view statuses for a nodetool command. So it's a no-op. Now we want to re-use the method for QueryTester
, but the useless exception replacement gets in the way and hides the original exception, which we want for our test checks.
Do you agree on simply removing the try-catch block, since it doesn't seem to use any purpose? Or I can add a variant of the QueryProcessor#execute
method without the exception replacement, or even embed it in CQLTester#executeFormattedQuery
, given how simple it is.
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.
Ok, let's remove it, convinced. Just trying not to break something and being extra cautious.
test/unit/org/apache/cassandra/index/sai/cql/GenericOrderByTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/index/sai/cql/InetAddressTypeEquivalencyTest.java
Outdated
Show resolved
Hide resolved
test/unit/org/apache/cassandra/nodes/virtual/LegacySystemKeyspaceToNodesTest.java
Show resolved
Hide resolved
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.
Overall LGTM, left some minor questions.
@@ -516,19 +516,28 @@ public static UntypedResultSet execute(String query, ConsistencyLevel cl, Object | |||
public static UntypedResultSet execute(String query, ConsistencyLevel cl, QueryState state, Object... values) | |||
throws RequestExecutionException | |||
{ | |||
try |
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.
who simply swallows the exception making this wrapping of RequestValidationException no-op
Could this be an actual bug?
Also, it seems Sonar complains about test coverage in this area.
test/unit/org/apache/cassandra/index/sai/cql/GenericOrderByTest.java
Outdated
Show resolved
Hide resolved
I am looking into CI results again now - seems like NodeStartupTest is a new regression even if it was not marked by Butler? Butler marked a lot of tests for regressions. We need to ensure they match previous failures on |
349fc17
to
73a5234
Compare
The latest changes LGTM but what do we do about
|
Ah, I've missed that one! I think the node restart simulated by I'm simply disabling coordinator execution on |
+1, let's do that, please |
Do you mean here or in a follow-up patch? |
Hm, sorry, I thought you suggest to make it here so we are sure no regressions. If it is not too much work, let's do it here while on top of it, please. |
I don't see how calling the same method in the same context is going to produce a regression, this seems more about using this to improve a previously existing test. I think it's likely I'll have to switch contexts this week, but I'll retake this patch with the port to dtests as soon as possible. |
I didn't see you were so quick to add a patch. :-) If you don't have time to add distributed test now let's commit the current PR and get to test improvement when the heat goes down a bit. I don't want to keep this improvement back. |
…Internal in CQL utests
SAI queries using inet should be fixed independently by CNDB-12978
This tries not to give the idea that the execution will involve multiple nodes.
This fixes failures in VectorSiftSmallTest due to parallel writes
b67a802
to
447270e
Compare
Ok, I've created #13125 as a follow-up for investigating and improving/porting |
|
✔️ Build ds-cassandra-pr-gate/PR-1564 approved by ButlerApproved by Butler |
Many if not most of our unit tests extend
CQLTester
.CQLTester#execute
executes CQL queries withReadQuery#executeInternal
, which is what is used for internal system queries, and it's pretty similar to the local execution done by replica nodes. This misses the full validation and all the reconciliation patch used byReadQuery#execute
.Missing reconciliation is particularly problematic for utests querying secondary indexes, because they miss the application of the full
RowFilter
by the coordinator.A more realistic behaviour can be achieved by using
CQLTester#executeNet
, which will use a driver session that will exercise the entire path. However, this has to be done manually in every test and it's easy to miss whenexecuteNet
is necessary. Also,executeNet
enables more serialization stuff that is costly in terms of resources and not that interesting for most cases.This PR adds a new
CQLTester#executeDistributed
method that makes the query go throughReadQuery#execute
rather thanReadQuery#executeInternal
.It also adds a new
CQLTester.enableDistributedExecution
method that changes the default behaviour ofCQLTester#execute
, so we can easily modify the query execution behaviour of entire tests. I haven't been brave enough to update allCQLTester
-based unit tests, but I have changed all SAI tests to use this new way of running queries. Let's see how many things this breaks in CI.CC @michaeljmarshall