You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2019/06/03 17:53:46 UTC

[kudu] 03/06: [java] Fix ordering bug in AsyncKuduSession

This is an automated email from the ASF dual-hosted git repository.

granthenke pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 1b4910977763efbfe9bc569414703f53c77d0d34
Author: Will Berkeley <wd...@gmail.com>
AuthorDate: Sun Jun 2 22:49:34 2019 -0700

    [java] Fix ordering bug in AsyncKuduSession
    
    AsyncKuduSession.testBatchErrorCauseSessionStuck occasionally failed
    because AsyncKuduSession#hasPendingOperations returned true even though
    the test joined on the deferred results of its two inserts. I tracked
    this down to a small mis-ordering of lines where the AsyncKuduSession
    fires a flush notification (from a Netty worker thread) before it
    actually swaps the just-flushed buffer back to the inactive list, so
    there was a small window of time when the client thread could observe
    hasPendingOperations() as true even though there were no pending
    operations.
    
    I ran the test 100 times in dist-test with this fix and saw no failures.
    I didn't run the test pre-fix through dist-test but the flaky dashboard
    indicated it was 2-3% flaky.
    
    Change-Id: I498636aeb0de2673c15b90260e6acf56de1ead06
    Reviewed-on: http://gerrit.cloudera.org:8080/13496
    Tested-by: Kudu Jenkins
    Reviewed-by: Grant Henke <gr...@apache.org>
---
 .../src/main/java/org/apache/kudu/client/AsyncKuduSession.java          | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduSession.java b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduSession.java
index a9c8720..ba52727 100644
--- a/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduSession.java
+++ b/java/kudu-client/src/main/java/org/apache/kudu/client/AsyncKuduSession.java
@@ -307,9 +307,9 @@ public class AsyncKuduSession implements SessionConfiguration {
    * @param buffer the buffer to return to the inactive queue.
    */
   private void queueBuffer(Buffer buffer) {
+    inactiveBuffers.add(buffer);
     buffer.callbackFlushNotification();
     Deferred<Void> localFlushNotification = flushNotification.getAndSet(new Deferred<Void>());
-    inactiveBuffers.add(buffer);
     localFlushNotification.callback(null);
   }