You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by eo...@apache.org on 2018/09/05 12:54:47 UTC

[bookkeeper] branch branch-4.8 updated: Avoid releasing sent buffer to early in BookieClient mock

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

eolivelli pushed a commit to branch branch-4.8
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/branch-4.8 by this push:
     new b5065b9  Avoid releasing sent buffer to early in BookieClient mock
b5065b9 is described below

commit b5065b9479404948b231ab55d5df561211579cb1
Author: Ivan Kelly <iv...@apache.org>
AuthorDate: Wed Sep 5 14:54:32 2018 +0200

    Avoid releasing sent buffer to early in BookieClient mock
    
    Cherry pick tp branch-4.8 commit https://github.com/apache/bookkeeper/commit/6b9cbf2052b27f331553f2738483ae21bf12b49c from Ivan Kelly
    
    If the buffer was sent to more than one bookie with the mock, it would
    be released after being sent to the first one. Each write should
    retain a refCount themselves, and then release when done.
    
    Author: Ivan Kelly <ivankapache.org>
    
    Relates to #1598, closes #1643
    
    Author: Ivan Kelly <iv...@apache.org>
    
    Reviewers: Sijie Guo <si...@apache.org>
    
    This closes #1651 from eolivelli/fix/cherry-pick-mock-client-tests-errors
---
 .../java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java     | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java
index 6e1557a..20a8bb8 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/MockBookKeeperTestCase.java
@@ -511,6 +511,7 @@ public abstract class MockBookKeeperTestCase {
             boolean isRecoveryAdd =
                 ((short) options & BookieProtocol.FLAG_RECOVERY_ADD) == BookieProtocol.FLAG_RECOVERY_ADD;
 
+            toSend.retain();
             executor.executeOrdered(ledgerId, () -> {
                 byte[] entry;
                 try {
@@ -518,6 +519,7 @@ public abstract class MockBookKeeperTestCase {
                 } catch (BKDigestMatchException e) {
                     callback.writeComplete(Code.DigestMatchException,
                             ledgerId, entryId, bookieSocketAddress, ctx);
+                    toSend.release();
                     return;
                 }
                 boolean fenced = fencedLedgers.contains(ledgerId);
@@ -528,6 +530,7 @@ public abstract class MockBookKeeperTestCase {
                     if (failedBookies.contains(bookieSocketAddress)) {
                         callback.writeComplete(NoBookieAvailableException,
                                 ledgerId, entryId, bookieSocketAddress, ctx);
+                        toSend.release();
                         return;
                     }
                     if (getMockLedgerContentsInBookie(ledgerId, bookieSocketAddress).isEmpty()) {
@@ -538,6 +541,7 @@ public abstract class MockBookKeeperTestCase {
                     callback.writeComplete(BKException.Code.OK,
                             ledgerId, entryId, bookieSocketAddress, ctx);
                 }
+                toSend.release();
             });
 
             return null;