You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by yo...@apache.org on 2022/10/26 01:11:42 UTC

[bookkeeper] branch branch-4.15 updated (3e454c3e4a -> ce2ed41af0)

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

yong pushed a change to branch branch-4.15
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


    from 3e454c3e4a Make the rocksDB configuration compatible with previous versions (#3523)
     new 15fb058c8d Issue 3070: Fix bug where checkAllLedgers gets stuck when read throttling is enabled (#3214)
     new 5a4f9278af fix close ledgerAuditorManager repeatedly (#3503)
     new d1f72b4ac6 Rename success with writableResult and update final writableResult about wait writeSet (#3505)
     new e2e1115661 Reduce unnecessary loop in removeIf if section is empty (#3512)
     new 6c3586a157 Bump jackson version to 2.13.4 (#3518)
     new ede7c19bb1 Fix byteBuf potential memory leak problem. (#3525)
     new 3a95424ed0 Fix memory leak when reading entry but the connection disconnected. (#3528)
     new 2144ac321f fix flaky-test testWriteSetWriteableCheck (#3555)
     new 9db36f9b8a skipping placementPolicyCheck when ledger replication disabled (#3561)
     new 452f7a744a Flush time started moved to after lock (#3570)
     new ce2ed41af0 update ALLOCATOR_POOLING_CONCURRENCY default value (#3001)

The 11 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../src/main/resources/LICENSE-all.bin.txt         |  6 +--
 .../src/main/resources/LICENSE-bkctl.bin.txt       |  6 +--
 .../src/main/resources/LICENSE-server.bin.txt      |  6 +--
 .../ldb/SingleDirectoryDbLedgerStorage.java        | 11 +++++-
 .../apache/bookkeeper/client/LedgerChecker.java    |  9 ++++-
 .../org/apache/bookkeeper/client/LedgerHandle.java | 19 +++++-----
 .../bookkeeper/conf/AbstractConfiguration.java     |  3 +-
 .../apache/bookkeeper/proto/BookieProtocol.java    | 43 +++++++++++++++++-----
 .../bookkeeper/proto/PacketProcessorBase.java      | 25 ++++++++++---
 .../org/apache/bookkeeper/replication/Auditor.java |  7 ++++
 .../bookkeeper/replication/AuditorElector.java     |  7 +---
 .../util/collections/ConcurrentLongHashMap.java    |  2 +-
 .../collections/ConcurrentLongLongHashMap.java     |  4 +-
 .../util/collections/ConcurrentOpenHashMap.java    |  2 +-
 .../apache/bookkeeper/client/SlowBookieTest.java   | 41 +++++++++++++++++++++
 .../bookkeeper/client/TestLedgerChecker.java       |  2 +-
 .../bookkeeper/proto/WriteEntryProcessorTest.java  | 20 +++++++---
 pom.xml                                            |  2 +-
 18 files changed, 159 insertions(+), 56 deletions(-)


[bookkeeper] 08/11: fix flaky-test testWriteSetWriteableCheck (#3555)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 2144ac321f0ba25f713b6c3bd247172bf5387c08
Author: wenbingshen <ol...@gmail.com>
AuthorDate: Mon Oct 24 09:53:27 2022 +0800

    fix flaky-test testWriteSetWriteableCheck (#3555)
    
    ### Motivation
     `testWriteSetWriteableCheck` always failed. After investigation, it is found that `isWritable=false` is set when the simulated channel is not writable, but the unit test cannot fully perceive the channel establishment, because the channel is completely established asynchronously. The isWritable state of false is changed to true again.
    
    you can see the following logs:
    ![image](https://user-images.githubusercontent.com/35599757/196625314-0ea5a305-9564-4738-8055-20baa6a5c5a2.png)
    
    The smallest change is that we can ensure that the channel is established before changing the channel state, such as executing `bkc.getBookieInfo()`, and then `setTargetChannelState`
    
    (cherry picked from commit c76e549fc93efb290adac9f7e295f44145772670)
---
 .../src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java    | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
index b8e5d2495d..9decf67ce7 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
@@ -323,6 +323,10 @@ public class SlowBookieTest extends BookKeeperClusterTestCase {
             // b2 or b3 is no more writeable
             int slowBookieIndex = writeSet.get(ThreadLocalRandom.current().nextInt(writeSet.size()));
             List<BookieId> curEns = lh.getCurrentEnsemble();
+
+            // Trigger connection to the bookie service first
+            bkc.getBookieInfo().get(curEns.get(slowBookieIndex));
+            // then mock channel is not writable
             setTargetChannelState(bkc, curEns.get(slowBookieIndex), 0, false);
 
             boolean isWriteable = lh.waitForWritable(writeSet, 0, 1000);


[bookkeeper] 03/11: Rename success with writableResult and update final writableResult about wait writeSet (#3505)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit d1f72b4ac6bd411927c59a29c28870a61f465371
Author: wenbingshen <ol...@gmail.com>
AuthorDate: Wed Oct 19 14:30:05 2022 +0800

    Rename success with writableResult and update final writableResult about wait writeSet (#3505)
    
    ### Changes
    update `success` about wait writeSet for Writable result.
    
    (cherry picked from commit 2e1a2f0acd56e7f327e7fddd17d8a39d8f8fdbdf)
---
 .../org/apache/bookkeeper/client/LedgerHandle.java | 19 +++++------
 .../apache/bookkeeper/client/SlowBookieTest.java   | 37 ++++++++++++++++++++++
 2 files changed, 47 insertions(+), 9 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
index 316cc7d32d..50fc2d6624 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java
@@ -1256,14 +1256,14 @@ public class LedgerHandle implements WriteHandle {
         }
 
         final long startTime = MathUtils.nowInNano();
-        boolean success = isWriteSetWritable(writeSet, allowedNonWritableCount);
+        boolean writableResult = isWriteSetWritable(writeSet, allowedNonWritableCount);
 
-        if (!success && durationMs > 0) {
+        if (!writableResult && durationMs > 0) {
             int backoff = 1;
             final int maxBackoff = 4;
             final long deadline = startTime + TimeUnit.MILLISECONDS.toNanos(durationMs);
 
-            while (!isWriteSetWritable(writeSet, allowedNonWritableCount)) {
+            while (!(writableResult = isWriteSetWritable(writeSet, allowedNonWritableCount))) {
                 if (MathUtils.nowInNano() < deadline) {
                     long maxSleep = MathUtils.elapsedMSec(startTime);
                     if (maxSleep < 0) {
@@ -1275,32 +1275,33 @@ public class LedgerHandle implements WriteHandle {
                         TimeUnit.MILLISECONDS.sleep(sleepMs);
                     } catch (InterruptedException e) {
                         Thread.currentThread().interrupt();
-                        success = isWriteSetWritable(writeSet, allowedNonWritableCount);
+                        writableResult = isWriteSetWritable(writeSet, allowedNonWritableCount);
                         break;
                     }
                     if (backoff <= maxBackoff) {
                         backoff++;
                     }
                 } else {
-                    success = false;
+                    writableResult = false;
                     break;
                 }
             }
             if (backoff > 1) {
-                LOG.info("Spent {} ms waiting for {} writable channels",
+                LOG.info("Spent {} ms waiting for {} writable channels, writable result {}",
                         MathUtils.elapsedMSec(startTime),
-                        writeSet.size() - allowedNonWritableCount);
+                        writeSet.size() - allowedNonWritableCount,
+                        writableResult);
             }
         }
 
-        if (success) {
+        if (writableResult) {
             clientChannelWriteWaitStats.registerSuccessfulEvent(
                     MathUtils.elapsedNanos(startTime), TimeUnit.NANOSECONDS);
         } else {
             clientChannelWriteWaitStats.registerFailedEvent(
                     MathUtils.elapsedNanos(startTime), TimeUnit.NANOSECONDS);
         }
-        return success;
+        return writableResult;
     }
 
     protected void doAsyncAddEntry(final PendingAddOp op) {
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
index 02ecf45ee5..b8e5d2495d 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
@@ -38,6 +38,7 @@ import org.apache.bookkeeper.net.BookieId;
 import org.apache.bookkeeper.proto.BookieClientImpl;
 import org.apache.bookkeeper.proto.BookkeeperInternalCallbacks.GenericCallback;
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
+import org.awaitility.Awaitility;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -392,4 +393,40 @@ public class SlowBookieTest extends BookKeeperClusterTestCase {
         checklatch.await();
         assertEquals("There should be no missing fragments", 0, numFragments.get());
     }
+
+    @Test
+    public void testWaitForWritable() throws Exception {
+        final ClientConfiguration conf = new ClientConfiguration();
+        conf.setMetadataServiceUri(zkUtil.getMetadataServiceUri());
+        BookKeeper bkc = new BookKeeper(conf);
+
+        byte[] pwd = new byte[]{};
+        try (LedgerHandle lh = bkc.createLedger(1, 1, 1, BookKeeper.DigestType.CRC32, pwd)) {
+            long entryId = lh.addEntry(this.entry);
+
+            RoundRobinDistributionSchedule schedule = new RoundRobinDistributionSchedule(1, 1, 1);
+            DistributionSchedule.WriteSet writeSet = schedule.getWriteSet(entryId);
+
+            int slowBookieIndex = writeSet.get(ThreadLocalRandom.current().nextInt(writeSet.size()));
+            List<BookieId> curEns = lh.getCurrentEnsemble();
+
+            // disable channel writable
+            setTargetChannelState(bkc, curEns.get(slowBookieIndex), 0, false);
+
+            AtomicBoolean isWriteable = new AtomicBoolean(false);
+            final long timeout = 10000;
+
+            // waitForWritable async
+           new Thread(() -> {
+                isWriteable.set(lh.waitForWritable(writeSet, 0, timeout));
+            }).start();
+            TimeUnit.MILLISECONDS.sleep(5000);
+            assertFalse(isWriteable.get());
+
+            // enable channel writable
+            setTargetChannelState(bkc, curEns.get(slowBookieIndex), 0, true);
+            Awaitility.await().untilAsserted(() -> assertTrue(isWriteable.get()));
+        }
+    }
+
 }


[bookkeeper] 04/11: Reduce unnecessary loop in removeIf if section is empty (#3512)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit e2e1115661509e650d4a5c789a958e2e0cd617e4
Author: 萧易客 <km...@live.com>
AuthorDate: Sat Oct 8 10:24:28 2022 +0800

    Reduce unnecessary loop in removeIf if section is empty (#3512)
    
    Reduce unnecessary loop in removeIf if section is empty
    
    (cherry picked from commit bc87bfbea5816b382a7fe54639d71b404736ba62)
---
 .../org/apache/bookkeeper/util/collections/ConcurrentLongHashMap.java | 2 +-
 .../apache/bookkeeper/util/collections/ConcurrentLongLongHashMap.java | 4 ++--
 .../org/apache/bookkeeper/util/collections/ConcurrentOpenHashMap.java | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashMap.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashMap.java
index dd2b6c1bc8..be11a4ebc3 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashMap.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongHashMap.java
@@ -533,7 +533,7 @@ public class ConcurrentLongHashMap<V> {
             try {
                 // Go through all the buckets for this section
                 int capacity = this.capacity;
-                for (int bucket = 0; bucket < capacity; bucket++) {
+                for (int bucket = 0; size > 0 && bucket < capacity; bucket++) {
                     long storedKey = keys[bucket];
                     V storedValue = values[bucket];
 
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongHashMap.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongHashMap.java
index 99a3dde772..f54a9645ac 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongHashMap.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentLongLongHashMap.java
@@ -682,7 +682,7 @@ public class ConcurrentLongLongHashMap {
             int removedCount = 0;
             try {
                 // Go through all the buckets for this section
-                for (int bucket = 0; bucket < table.length; bucket += 2) {
+                for (int bucket = 0; size > 0 && bucket < table.length; bucket += 2) {
                     long storedKey = table[bucket];
 
                     if (storedKey != DeletedKey && storedKey != EmptyKey) {
@@ -720,7 +720,7 @@ public class ConcurrentLongLongHashMap {
             int removedCount = 0;
             try {
                 // Go through all the buckets for this section
-                for (int bucket = 0; bucket < table.length; bucket += 2) {
+                for (int bucket = 0; size > 0 && bucket < table.length; bucket += 2) {
                     long storedKey = table[bucket];
                     long storedValue = table[bucket + 1];
 
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentOpenHashMap.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentOpenHashMap.java
index 2690e69766..b4de6544ce 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentOpenHashMap.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/util/collections/ConcurrentOpenHashMap.java
@@ -528,7 +528,7 @@ public class ConcurrentOpenHashMap<K, V> {
             int removedCount = 0;
             try {
                 // Go through all the buckets for this section
-                for (int bucket = 0; bucket < table.length; bucket += 2) {
+                for (int bucket = 0; size > 0 && bucket < table.length; bucket += 2) {
                     K storedKey = (K) table[bucket];
                     V storedValue = (V) table[bucket + 1];
 


[bookkeeper] 09/11: skipping placementPolicyCheck when ledger replication disabled (#3561)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 9db36f9b8aa4ce71e57d2f0ae9ee4f5506cb6943
Author: wenbingshen <ol...@gmail.com>
AuthorDate: Tue Oct 25 09:49:44 2022 +0800

    skipping placementPolicyCheck when ledger replication disabled (#3561)
    
    ### Motivation
    
    When `placementPolicyCheck` is enabled and then `bookkeeper shell autorecovery -disable` is executed, `placementPolicyCheck` will detect ledgers that do not satisfy `placementPolicy` and write to zookeeper, but `ReplicationWorker` no longer obtains ledgers from zookeeper for replication work because autorecovery is disabled, which results in a large number of temporary nodes on zookeeper , when there are more ledgers that do not satisfy placementPolicy, the problem will get worse.
    
    The method of `ReplicationWorker` to get ledger:
    ```java
    private boolean rereplicate() throws InterruptedException, BKException,
                UnavailableException {
            long ledgerIdToReplicate = underreplicationManager
                    .getLedgerToRereplicate();
    
           ...
    ```
    
    So we should also disable `placementPolicyCheck`.
    
    (cherry picked from commit cfc6b9770f2189b17ac9ce61c763b4ce6a2d7e55)
---
 .../src/main/java/org/apache/bookkeeper/replication/Auditor.java   | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
index 428f763ea7..8afb0cc74f 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/Auditor.java
@@ -880,6 +880,11 @@ public class Auditor implements AutoCloseable {
                 @Override
                 public void run() {
                     try {
+                        if (!ledgerUnderreplicationManager.isLedgerReplicationEnabled()) {
+                            LOG.info("Ledger replication disabled, skipping placementPolicyCheck");
+                            return;
+                        }
+
                         Stopwatch stopwatch = Stopwatch.createStarted();
                         LOG.info("Starting PlacementPolicyCheck");
                         placementPolicyCheck();
@@ -955,6 +960,8 @@ public class Auditor implements AutoCloseable {
                                 numOfLedgersFoundInPlacementPolicyCheckValue,
                                 numOfLedgersFoundSoftlyAdheringInPlacementPolicyCheckValue,
                                 numOfURLedgersElapsedRecoveryGracePeriodValue, e);
+                    } catch (ReplicationException.UnavailableException ue) {
+                        LOG.error("Underreplication manager unavailable running periodic check", ue);
                     }
                 }
             }), initialDelay, interval, TimeUnit.SECONDS);


[bookkeeper] 10/11: Flush time started moved to after lock (#3570)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 452f7a744a2d9336e567f34e9f73c56332a6f3b1
Author: zhaohaidao <zh...@hotmail.com>
AuthorDate: Tue Oct 25 11:28:29 2022 +0800

    Flush time started moved to after lock (#3570)
    
    ### Motivation
    
    In BP-44(Ledger storage metrics enhancement), ledger flush start time is moved to after lock to avoid 200% time
      utilization calculations.
    However, 200% time utilization still happens in my test. After reading the source code, I found that this part was rolled back by #3160.
    If I understand correctly, this change is not as expected
    
    ### Changes
    
    Flush start time is moved to after lock again.
    
    (cherry picked from commit c97b57635bb65551ebf149ba458a73a056129bb9)
---
 .../bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
index f8ffcb9ee9..1777e2e1c1 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/SingleDirectoryDbLedgerStorage.java
@@ -701,10 +701,17 @@ public class SingleDirectoryDbLedgerStorage implements CompactableLedgerStorage
             return;
         }
 
-        long startTime = MathUtils.nowInNano();
-
         // Only a single flush operation can happen at a time
         flushMutex.lock();
+        long startTime = -1;
+        try {
+            startTime = MathUtils.nowInNano();
+        } catch (Throwable e) {
+            // Fix spotbugs warning. Should never happen
+            flushMutex.unlock();
+            throw new IOException(e);
+        }
+
         try {
             if (writeCache.isEmpty()) {
                 return;


[bookkeeper] 06/11: Fix byteBuf potential memory leak problem. (#3525)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ede7c19bb10cd108bec834b785062b6d41fd06bb
Author: Yan Zhao <ho...@apache.org>
AuthorDate: Thu Oct 13 10:42:01 2022 +0800

    Fix byteBuf potential memory leak problem. (#3525)
    
    * Fix byteBuf potential memory leak problem.
    
    (cherry picked from commit 62155369d199f36720938e913541b223dab8b047)
---
 .../main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java  | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java
index 07954d746a..c1bf977956 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java
@@ -109,6 +109,9 @@ abstract class PacketProcessorBase<T extends Request> extends SafeRunnable {
                 requestProcessor.getRequestStats().getChannelWriteStats()
                     .registerFailedEvent(MathUtils.elapsedNanos(writeNanos), TimeUnit.NANOSECONDS);
                 statsLogger.registerFailedEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS);
+                if (response instanceof BookieProtocol.ReadResponse) {
+                    ((BookieProtocol.ReadResponse) response).release();
+                }
                 return;
             } else {
                 requestProcessor.invalidateBlacklist(channel);
@@ -118,6 +121,9 @@ abstract class PacketProcessorBase<T extends Request> extends SafeRunnable {
         if (channel.isActive()) {
             channel.writeAndFlush(response, channel.voidPromise());
         } else {
+            if (response instanceof BookieProtocol.ReadResponse) {
+                ((BookieProtocol.ReadResponse) response).release();
+            }
             LOGGER.debug("Netty channel {} is inactive, "
                     + "hence bypassing netty channel writeAndFlush during sendResponse", channel);
         }


[bookkeeper] 05/11: Bump jackson version to 2.13.4 (#3518)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 6c3586a157acd369668278b4808d701c1f73dfdb
Author: ZhangJian He <sh...@gmail.com>
AuthorDate: Sun Oct 9 11:47:29 2022 +0800

    Bump jackson version to 2.13.4 (#3518)
    
    Bump jackson version to 2.13.4 to solve CVE-2022-42004
    
    (cherry picked from commit 6e43c0a8c6447ada7b1cf46243396ea1abfe01b9)
---
 bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt    | 6 +++---
 bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt  | 6 +++---
 bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt | 6 +++---
 pom.xml                                                   | 2 +-
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt b/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt
index 8fcebb12b5..98efa359c9 100644
--- a/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt
+++ b/bookkeeper-dist/src/main/resources/LICENSE-all.bin.txt
@@ -205,9 +205,9 @@
 The following bundled 3rd party jars are distributed under the
 Apache Software License, Version 2.
 
-- lib/com.fasterxml.jackson.core-jackson-annotations-2.13.2.jar [1]
-- lib/com.fasterxml.jackson.core-jackson-core-2.13.2.jar [2]
-- lib/com.fasterxml.jackson.core-jackson-databind-2.13.2.2.jar [3]
+- lib/com.fasterxml.jackson.core-jackson-annotations-2.13.4.jar [1]
+- lib/com.fasterxml.jackson.core-jackson-core-2.13.4.jar [2]
+- lib/com.fasterxml.jackson.core-jackson-databind-2.13.4.jar [3]
 - lib/com.google.guava-guava-31.0.1-jre.jar [4]
 - lib/com.google.guava-failureaccess-1.0.1.jar [4]
 - lib/com.google.guava-listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar [4]
diff --git a/bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt b/bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt
index 5b7421d020..a8122c5675 100644
--- a/bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt
+++ b/bookkeeper-dist/src/main/resources/LICENSE-bkctl.bin.txt
@@ -205,9 +205,9 @@
 The following bundled 3rd party jars are distributed under the
 Apache Software License, Version 2.
 
-- lib/com.fasterxml.jackson.core-jackson-annotations-2.13.2.jar [1]
-- lib/com.fasterxml.jackson.core-jackson-core-2.13.2.jar [2]
-- lib/com.fasterxml.jackson.core-jackson-databind-2.13.2.2.jar [3]
+- lib/com.fasterxml.jackson.core-jackson-annotations-2.13.4.jar [1]
+- lib/com.fasterxml.jackson.core-jackson-core-2.13.4.jar [2]
+- lib/com.fasterxml.jackson.core-jackson-databind-2.13.4.jar [3]
 - lib/com.google.guava-guava-31.0.1-jre.jar [4]
 - lib/com.google.guava-failureaccess-1.0.1.jar [4]
 - lib/com.google.guava-listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar [4]
diff --git a/bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt b/bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt
index e3dc9c2078..8cdf679c2a 100644
--- a/bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt
+++ b/bookkeeper-dist/src/main/resources/LICENSE-server.bin.txt
@@ -205,9 +205,9 @@
 The following bundled 3rd party jars are distributed under the
 Apache Software License, Version 2.
 
-- lib/com.fasterxml.jackson.core-jackson-annotations-2.13.2.jar [1]
-- lib/com.fasterxml.jackson.core-jackson-core-2.13.2.jar [2]
-- lib/com.fasterxml.jackson.core-jackson-databind-2.13.2.2.jar [3]
+- lib/com.fasterxml.jackson.core-jackson-annotations-2.13.4.jar [1]
+- lib/com.fasterxml.jackson.core-jackson-core-2.13.4.jar [2]
+- lib/com.fasterxml.jackson.core-jackson-databind-2.13.4.jar [3]
 - lib/com.google.guava-guava-31.0.1-jre.jar [4]
 - lib/com.google.guava-failureaccess-1.0.1.jar [4]
 - lib/com.google.guava-listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar [4]
diff --git a/pom.xml b/pom.xml
index ec72d10d40..d9b14dd3a9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -141,7 +141,7 @@
     <hadoop.version>3.2.4</hadoop.version>
     <hamcrest.version>1.3</hamcrest.version>
     <hdrhistogram.version>2.1.10</hdrhistogram.version>
-    <jackson.version>2.13.2.20220328</jackson.version>
+    <jackson.version>2.13.4</jackson.version>
     <jcommander.version>1.78</jcommander.version>
     <jetty.version>9.4.48.v20220622</jetty.version>
     <jmh.version>1.19</jmh.version>


[bookkeeper] 01/11: Issue 3070: Fix bug where checkAllLedgers gets stuck when read throttling is enabled (#3214)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 15fb058c8d6cddd8c899392c783da9145e32b7bc
Author: Masahiro Sakamoto <ma...@yahoo-corp.jp>
AuthorDate: Thu Sep 29 22:39:24 2022 +0900

    Issue 3070: Fix bug where checkAllLedgers gets stuck when read throttling is enabled (#3214)
    
    (cherry picked from commit 21560fb9afd9da61231a709c0b86a1a7b2d0f8b0)
---
 .../main/java/org/apache/bookkeeper/client/LedgerChecker.java    | 9 +++++++--
 .../java/org/apache/bookkeeper/client/TestLedgerChecker.java     | 2 +-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java
index f3a49d31a6..68c6adb0b0 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerChecker.java
@@ -26,6 +26,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeSet;
+import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.Semaphore;
 import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -425,6 +426,11 @@ public class LedgerChecker {
             if (curEntryId == lastEntry) {
                 final long entryToRead = curEntryId;
 
+                final CompletableFuture<Void> future = new CompletableFuture<>();
+                future.whenCompleteAsync((re, ex) -> {
+                    checkFragments(fragments, cb, percentageOfLedgerFragmentToBeVerified);
+                });
+
                 final EntryExistsCallback eecb = new EntryExistsCallback(lh.getLedgerMetadata().getWriteQuorumSize(),
                                               new GenericCallback<Boolean>() {
                                                   @Override
@@ -432,8 +438,7 @@ public class LedgerChecker {
                                                       if (result) {
                                                           fragments.add(lastLedgerFragment);
                                                       }
-                                                      checkFragments(fragments, cb,
-                                                          percentageOfLedgerFragmentToBeVerified);
+                                                      future.complete(null);
                                                   }
                                               });
 
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerChecker.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerChecker.java
index d78d1599f9..43122205e9 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerChecker.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestLedgerChecker.java
@@ -518,7 +518,7 @@ public class TestLedgerChecker extends BookKeeperClusterTestCase {
 
     private Set<LedgerFragment> getUnderReplicatedFragments(LedgerHandle lh)
             throws InterruptedException {
-        LedgerChecker checker = new LedgerChecker(bkc);
+        LedgerChecker checker = new LedgerChecker(bkc, 1);
         CheckerCallback cb = new CheckerCallback();
         checker.checkLedger(lh, cb);
         Set<LedgerFragment> result = cb.waitAndGetResult();


[bookkeeper] 02/11: fix close ledgerAuditorManager repeatedly (#3503)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5a4f9278afb1e0a3cd9067dd3e79c4ee7c55a285
Author: wenbingshen <ol...@gmail.com>
AuthorDate: Wed Oct 19 14:30:48 2022 +0800

    fix close ledgerAuditorManager repeatedly (#3503)
    
    ### Motivation
    this introduced in #2842, the `ledgerAuditorManager` will be close repeatedly.
    
    ```java
        private void submitShutdownTask() {
            executor.submit(new Runnable() {
                    @Override
                    public void run() {
                        if (!running.compareAndSet(true, false)) {
                            return;
                        }
    
                        try {
                            ledgerAuditorManager.close();   <- here has already closed LAM.
                        } catch (InterruptedException ie) {
                            Thread.currentThread().interrupt();
                            LOG.warn("InterruptedException while closing ledger auditor manager", ie);
                        } catch (Exception ke) {
                            LOG.error("Exception while closing ledger auditor manager", ke);
                        }
                    }
                });
        }
    ```
    
    (cherry picked from commit dbec4e91eca20566a4db1673e9db1d728f659960)
---
 .../java/org/apache/bookkeeper/replication/AuditorElector.java     | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
index eaab84c7b1..badd5fd26e 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AuditorElector.java
@@ -230,16 +230,11 @@ public class AuditorElector {
      * Shutting down AuditorElector.
      */
     public void shutdown() throws InterruptedException {
-        try {
-            ledgerAuditorManager.close();
-        } catch (Exception e) {
-            throw new RuntimeException(e);
-        }
-
         synchronized (this) {
             if (executor.isShutdown()) {
                 return;
             }
+            // close auditor manager
             submitShutdownTask();
             executor.shutdown();
         }


[bookkeeper] 07/11: Fix memory leak when reading entry but the connection disconnected. (#3528)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 3a95424ed0d9138d2b4c318c4ce2999a70891f1a
Author: Yan Zhao <ho...@apache.org>
AuthorDate: Tue Oct 18 14:21:54 2022 +0800

    Fix memory leak when reading entry but the connection disconnected. (#3528)
    
    * Fix direct memory leak problem
    
    (cherry picked from commit 30bdedc25a59aa7d4df3f5c0962095a574f0d653)
---
 .../apache/bookkeeper/proto/BookieProtocol.java    | 43 +++++++++++++++++-----
 .../bookkeeper/proto/PacketProcessorBase.java      | 27 +++++++++-----
 .../bookkeeper/proto/WriteEntryProcessorTest.java  | 20 +++++++---
 3 files changed, 65 insertions(+), 25 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java
index cc290b0673..965f3fd1bb 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/BookieProtocol.java
@@ -25,7 +25,7 @@ import io.netty.buffer.Unpooled;
 import io.netty.util.Recycler;
 import io.netty.util.Recycler.Handle;
 import io.netty.util.ReferenceCountUtil;
-
+import io.netty.util.ReferenceCounted;
 import org.apache.bookkeeper.proto.BookkeeperProtocol.AuthMessage;
 import org.apache.bookkeeper.util.ByteBufList;
 
@@ -433,10 +433,8 @@ public interface BookieProtocol {
                                  opCode, ledgerId, entryId, errorCode);
         }
 
-        void retain() {
-        }
-
-        void release() {
+        boolean release() {
+            return true;
         }
 
         void recycle() {
@@ -446,7 +444,7 @@ public interface BookieProtocol {
     /**
      * A request that reads data.
      */
-    class ReadResponse extends Response {
+    class ReadResponse extends Response implements ReferenceCounted {
         final ByteBuf data;
 
         ReadResponse(byte protocolVersion, int errorCode, long ledgerId, long entryId) {
@@ -467,13 +465,38 @@ public interface BookieProtocol {
         }
 
         @Override
-        public void retain() {
-            data.retain();
+        public int refCnt() {
+            return data.refCnt();
         }
 
         @Override
-        public void release() {
-            data.release();
+        public ReferenceCounted retain() {
+            return data.retain();
+        }
+
+        @Override
+        public ReferenceCounted retain(int increment) {
+            return data.retain(increment);
+        }
+
+        @Override
+        public ReferenceCounted touch() {
+            return data.touch();
+        }
+
+        @Override
+        public ReferenceCounted touch(Object hint) {
+            return data.touch(hint);
+        }
+
+        @Override
+        public boolean release() {
+            return data.release();
+        }
+
+        @Override
+        public boolean release(int decrement) {
+            return data.release(decrement);
         }
     }
 
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java
index c1bf977956..0fb2d3f8f0 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/proto/PacketProcessorBase.java
@@ -19,6 +19,8 @@ package org.apache.bookkeeper.proto;
 
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelPromise;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.TimeUnit;
 import org.apache.bookkeeper.proto.BookieProtocol.Request;
 import org.apache.bookkeeper.stats.OpStatsLogger;
@@ -104,13 +106,13 @@ abstract class PacketProcessorBase<T extends Request> extends SafeRunnable {
             }
 
             if (!channel.isWritable()) {
-                LOGGER.warn("cannot write response to non-writable channel {} for request {}", channel,
+                logger.warn("cannot write response to non-writable channel {} for request {}", channel,
                     StringUtils.requestToString(request));
                 requestProcessor.getRequestStats().getChannelWriteStats()
                     .registerFailedEvent(MathUtils.elapsedNanos(writeNanos), TimeUnit.NANOSECONDS);
                 statsLogger.registerFailedEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS);
-                if (response instanceof BookieProtocol.ReadResponse) {
-                    ((BookieProtocol.ReadResponse) response).release();
+                if (response instanceof BookieProtocol.Response) {
+                    ((BookieProtocol.Response) response).release();
                 }
                 return;
             } else {
@@ -119,12 +121,17 @@ abstract class PacketProcessorBase<T extends Request> extends SafeRunnable {
         }
 
         if (channel.isActive()) {
-            channel.writeAndFlush(response, channel.voidPromise());
+            ChannelPromise promise = channel.newPromise().addListener(future -> {
+                if (!future.isSuccess()) {
+                    logger.debug("Netty channel write exception. ", future.cause());
+                }
+            });
+            channel.writeAndFlush(response, promise);
         } else {
-            if (response instanceof BookieProtocol.ReadResponse) {
-                ((BookieProtocol.ReadResponse) response).release();
+            if (response instanceof BookieProtocol.Response) {
+                ((BookieProtocol.Response) response).release();
             }
-            LOGGER.debug("Netty channel {} is inactive, "
+            logger.debug("Netty channel {} is inactive, "
                     + "hence bypassing netty channel writeAndFlush during sendResponse", channel);
         }
         if (BookieProtocol.EOK == rc) {
@@ -145,12 +152,12 @@ abstract class PacketProcessorBase<T extends Request> extends SafeRunnable {
         try {
             ChannelFuture future = channel.writeAndFlush(response);
             if (!channel.eventLoop().inEventLoop()) {
-                future.await();
+                future.get();
             }
-        } catch (InterruptedException e) {
+        } catch (ExecutionException | InterruptedException e) {
+            logger.debug("Netty channel write exception. ", e);
             return;
         }
-
         if (BookieProtocol.EOK == rc) {
             statsLogger.registerSuccessfulEvent(MathUtils.elapsedNanos(enqueueNanos), TimeUnit.NANOSECONDS);
         } else {
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/WriteEntryProcessorTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/WriteEntryProcessorTest.java
index 150e0c3089..3ed939b796 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/WriteEntryProcessorTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/WriteEntryProcessorTest.java
@@ -101,7 +101,9 @@ public class WriteEntryProcessorTest {
     @Test
     public void testNoneHighPriorityWritesOnReadOnlyBookie() throws Exception {
         when(bookie.isReadOnly()).thenReturn(true);
-        when(channel.voidPromise()).thenReturn(mock(ChannelPromise.class));
+        ChannelPromise mockPromise = mock(ChannelPromise.class);
+        when(channel.newPromise()).thenReturn(mockPromise);
+        when(mockPromise.addListener(any())).thenReturn(mockPromise);
 
         AtomicReference<Object> writtenObject = new AtomicReference<>();
         CountDownLatch latch = new CountDownLatch(1);
@@ -131,7 +133,9 @@ public class WriteEntryProcessorTest {
 
         when(bookie.isReadOnly()).thenReturn(true);
         when(bookie.isAvailableForHighPriorityWrites()).thenReturn(false);
-        when(channel.voidPromise()).thenReturn(mock(ChannelPromise.class));
+        ChannelPromise mockPromise = mock(ChannelPromise.class);
+        when(channel.newPromise()).thenReturn(mockPromise);
+        when(mockPromise.addListener(any())).thenReturn(mockPromise);
 
         AtomicReference<Object> writtenObject = new AtomicReference<>();
         CountDownLatch latch = new CountDownLatch(1);
@@ -161,7 +165,9 @@ public class WriteEntryProcessorTest {
 
         when(bookie.isReadOnly()).thenReturn(true);
         when(bookie.isAvailableForHighPriorityWrites()).thenReturn(true);
-        when(channel.voidPromise()).thenReturn(mock(ChannelPromise.class));
+        ChannelPromise mockPromise = mock(ChannelPromise.class);
+        when(channel.newPromise()).thenReturn(mockPromise);
+        when(mockPromise.addListener(any())).thenReturn(mockPromise);
         doAnswer(invocationOnMock -> {
             processor.writeComplete(0, request.ledgerId, request.entryId, null, null);
             return null;
@@ -194,7 +200,9 @@ public class WriteEntryProcessorTest {
     @Test
     public void testNormalWritesOnWritableBookie() throws Exception {
         when(bookie.isReadOnly()).thenReturn(false);
-        when(channel.voidPromise()).thenReturn(mock(ChannelPromise.class));
+        ChannelPromise mockPromise = mock(ChannelPromise.class);
+        when(channel.newPromise()).thenReturn(mockPromise);
+        when(mockPromise.addListener(any())).thenReturn(mockPromise);
         doAnswer(invocationOnMock -> {
             processor.writeComplete(0, request.ledgerId, request.entryId, null, null);
             return null;
@@ -227,7 +235,9 @@ public class WriteEntryProcessorTest {
     @Test
     public void testWritesCacheFlushTimeout() throws Exception {
         when(bookie.isReadOnly()).thenReturn(false);
-        when(channel.voidPromise()).thenReturn(mock(ChannelPromise.class));
+        ChannelPromise mockPromise = mock(ChannelPromise.class);
+        when(channel.newPromise()).thenReturn(mockPromise);
+        when(mockPromise.addListener(any())).thenReturn(mockPromise);
         when(channel.writeAndFlush(any())).thenReturn(mock(ChannelPromise.class));
         doAnswer(invocationOnMock -> {
             throw new BookieException.OperationRejectedException();


[bookkeeper] 11/11: update ALLOCATOR_POOLING_CONCURRENCY default value (#3001)

Posted by yo...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ce2ed41af0741eee4204997476097de77f1fc40b
Author: ssj <su...@gmail.com>
AuthorDate: Wed Jul 27 23:57:48 2022 +0800

    update ALLOCATOR_POOLING_CONCURRENCY default value (#3001)
    
    Set a more reasonable default value to avoid OutOfDirectMemoryError.
    
    Descriptions of the changes in this PR:
    
    ### Motivation
    The default value of  allocatorPoolingConcurrency is 2 * Runtime.getRuntime().availableProcessors(). It's used to specify the num of Arena in PooledByteBufAllocator.
    
    Assume:
    40 processors
    80 arena (processors*2)
    2 chunk per arena
    16MiB per chunk
    JVM's total direct mem should be larger then 80*2*16=2560MiB, otherwise OutOfDirectMemoryError occured.
    
    OutOfDirectMemoryError much more likely to occur in Docker, cause JDK versions earlier than Java SE 8U131 does not support Docker CPU limits.
    
    ### Changes
    Use Netty default arena num `PooledByteBufAllocator.defaultNumDirectArena()` as default allocatorPoolingConcurrency.
    
    (cherry picked from commit 01c882415714ecfcf11aaf77c86ae550bef6feb6)
---
 .../main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java    | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
index 25d41cbb7b..addfd41d47 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
@@ -27,6 +27,7 @@ import java.util.Map;
 
 import javax.net.ssl.SSLEngine;
 
+import io.netty.buffer.PooledByteBufAllocator;
 import lombok.extern.slf4j.Slf4j;
 
 import org.apache.bookkeeper.common.allocator.LeakDetectionPolicy;
@@ -1085,7 +1086,7 @@ public abstract class AbstractConfiguration<T extends AbstractConfiguration>
      * @return the configured pooling concurrency for the allocator.
      */
     public int getAllocatorPoolingConcurrency() {
-        return this.getInteger(ALLOCATOR_POOLING_CONCURRENCY, 2 * Runtime.getRuntime().availableProcessors());
+        return this.getInteger(ALLOCATOR_POOLING_CONCURRENCY, PooledByteBufAllocator.defaultNumDirectArena());
     }
 
     /**