[ https://issues.apache.org/jira/browse/CASSANDRA-16949?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17767933#comment-17767933 ]
Sam Tunnicliffe commented on CASSANDRA-16949: --------------------------------------------- {quote}So, the first thing is that client.awaitResponses() awaits two messages and returns regardless of whether it is successful. Only one message is being sent - the error message, so the statement always times out. Irrespective of whether the server completes its job or not, we expect the client to be disconnected {quote} {noformat} // Client needs to expect multiple responses or else awaitResponses returns // after the error is first received and we race between handling the exception // caused by remote disconnection and checking the connection status.{noformat} i.e. if we don't coerce the client into additional waiting, the client may not have finished reacting to the server closing the connection before we check. An alternative would be to add a sleep between the two: {code:java} client.awaitResponses(); TimeUnit.SECONDS.sleep(1); // Client has disconnected assertFalse(client.isConnected()); {code} {quote}we cannot guarantee the order of events will be retained on the client side. It is even more apparent in real deployments. {quote} I don't quite understand this. For sure we in a real deployment we cannot guarantee the order of events on the client side as we don't control the client, but we do in a test like this. {quote}we should implement the test differently - assert that the message was sent rather than received {quote} If I remember right (but it's been a while, sorry), then the reasoning for doing it this way was mostly that it was easier/cleaner/less invasive to have a custom test client that we could inspect than to modify the server side in a way that is only really useful for testing. {quote}we should expect some ack from the client before the server closes the connection {quote} Not really, the sending of the error response is really just an optimisation to try and avoid client side timeouts. It's especially optimistic given we have so little control over how disparate client implementations deal with errors/timeouts (and even stream tracking). The server doesn't need to wait for an ack before closing. > Fix flaky test org.apache.cassandra.transport.CQLConnectionTest > --------------------------------------------------------------- > > Key: CASSANDRA-16949 > URL: https://issues.apache.org/jira/browse/CASSANDRA-16949 > Project: Cassandra > Issue Type: Bug > Components: Test/unit > Reporter: David Capwell > Assignee: Jacek Lewandowski > Priority: Normal > Fix For: 5.x > > > https://app.circleci.com/pipelines/github/dcapwell/cassandra/1037/workflows/c728d370-49b9-41aa-bdfb-8c41cf0355d8/jobs/6577/parallel-runs/3 > {code} > [junit-timeout] Testsuite: org.apache.cassandra.transport.CQLConnectionTest > [junit-timeout] Testsuite: org.apache.cassandra.transport.CQLConnectionTest > Tests run: 9, Failures: 4, Errors: 0, Skipped: 0, Time elapsed: 12.926 sec > [junit-timeout] > [junit-timeout] Testcase: > handleCorruptionOfLargeMessageFrame(org.apache.cassandra.transport.CQLConnectionTest): > FAILED > [junit-timeout] null > [junit-timeout] junit.framework.AssertionFailedError > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:484) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:446) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.handleCorruptionOfLargeMessageFrame(CQLConnectionTest.java:217) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > [junit-timeout] at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > [junit-timeout] > [junit-timeout] > [junit-timeout] Testcase: > testNegativeEnvelopeBodySize(org.apache.cassandra.transport.CQLConnectionTest): > FAILED > [junit-timeout] expected:<[]0L> but was:<[52424]0L> > [junit-timeout] junit.framework.AssertionFailedError: expected:<[]0L> but > was:<[52424]0L> > [junit-timeout] at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > [junit-timeout] at > java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest$AllocationObserver.lambda$verifier$0(CQLConnectionTest.java:850) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:492) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:446) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testNegativeEnvelopeBodySize(CQLConnectionTest.java:326) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > [junit-timeout] at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > [junit-timeout] > [junit-timeout] > [junit-timeout] Testcase: > testUnrecoverableMessageDecodingErrors(org.apache.cassandra.transport.CQLConnectionTest): > FAILED > [junit-timeout] expected:<[]0L> but was:<[52424]0L> > [junit-timeout] junit.framework.AssertionFailedError: expected:<[]0L> but > was:<[52424]0L> > [junit-timeout] at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native > Method) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) > [junit-timeout] at > java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest$AllocationObserver.lambda$verifier$0(CQLConnectionTest.java:850) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testFrameCorruption(CQLConnectionTest.java:492) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testUnrecoverableMessageDecodingErrors(CQLConnectionTest.java:392) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > [junit-timeout] at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > [junit-timeout] > [junit-timeout] > [junit-timeout] Testcase: > testRecoverableEnvelopeDecodingErrors(org.apache.cassandra.transport.CQLConnectionTest): > FAILED > [junit-timeout] null > [junit-timeout] junit.framework.AssertionFailedError > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.runTest(CQLConnectionTest.java:430) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testEnvelopeDecodingErrors(CQLConnectionTest.java:292) > [junit-timeout] at > org.apache.cassandra.transport.CQLConnectionTest.testRecoverableEnvelopeDecodingErrors(CQLConnectionTest.java:264) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > [junit-timeout] at > java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > [junit-timeout] at > java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > [junit-timeout] > [junit-timeout] > [junit-timeout] Test org.apache.cassandra.transport.CQLConnectionTest FAILED > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org