[ https://issues.apache.org/jira/browse/ZOOKEEPER-2786?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16113399#comment-16113399 ]
ASF GitHub Bot commented on ZOOKEEPER-2786: ------------------------------------------- GitHub user afine opened a pull request: https://github.com/apache/zookeeper/pull/327 ZOOKEEPER-2786 Flaky test: org.apache.zookeeper.test.ClientTest.testNonExistingOpCode This is the third time this failure has popped up. This time it seemed to only impact tests run using NettyServerCnxnFactory (so it only impacts 3.5 and master) and I was able to get it to pop up with sufficient frequency when running the tests locally. The issue is caused by improper handling of netty's futures. When we call `channel.write(wrappedBuffer(sendBuffer));` the write is completed asynchronously. The close call `channel.close();` is also asynchronous. So we can run into the case where the close occurs before a write. This patch changes our close call to be a callback for the completion of an empty write. This way we are guaranteed that the channel has "drained" before a close. My primary concern with this patch is the channel being used while it is closing (between the write of an empty buffer and the execution of the close callback). I have added a `closingChannel` boolean to track that, which I believe is sufficient. Let me know if anyone finds a situation where that is not the case. You can merge this pull request into a Git repository by running: $ git pull https://github.com/afine/zookeeper ZOOKEEPER-2786_third_times_a_charm Alternatively you can review and apply these changes as the patch at: https://github.com/apache/zookeeper/pull/327.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #327 ---- commit 6e16b20cd2f768e9a027f1d9306ae8126188edb4 Author: Abraham Fine <af...@apache.org> Date: 2017-08-03T20:02:06Z ZOOKEEPER-2786: Flaky test: org.apache.zookeeper.test.ClientTest.testNonExistingOpCode ---- > Flaky test: org.apache.zookeeper.test.ClientTest.testNonExistingOpCode > ---------------------------------------------------------------------- > > Key: ZOOKEEPER-2786 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-2786 > Project: ZooKeeper > Issue Type: Bug > Affects Versions: 3.4.10, 3.5.3 > Reporter: Abraham Fine > Assignee: Abraham Fine > Fix For: 3.5.4, 3.6.0 > > > This test is broken on 3.4 and 3.5, but is broken in "different" ways. Please > see the individual pull requests for detailed descriptions for the issues > faced in both branches. -- This message was sent by Atlassian JIRA (v6.4.14#64029)