From 4cc13cb3cebc9e7ea2d1bb016f4c7b08d4700e39 Mon Sep 17 00:00:00 2001 From: teamconfx Date: Mon, 11 Sep 2023 22:53:13 +0800 Subject: [PATCH 1/4] prohibit user from set hbase.server.allocator.buffer.size to non-positive values --- .../java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java index 60b89223c169..02d3fcba434a 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java @@ -171,6 +171,10 @@ public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnab // that by the time a handler originated response is actually done writing to socket and so // released the BBs it used, the handler might have processed one more read req. On an avg 2x // we consider and consider that also for the max buffers to pool + if (poolBufSize <= 0) { + throw new IllegalArgumentException(BUFFER_SIZE_KEY + " must be positive. Please disable " + + "the reservoir rather than setting the size of the buffer to zero or negative."); + } int bufsForTwoMB = (2 * 1024 * 1024) / poolBufSize; int maxBuffCount = conf.getInt(MAX_BUFFER_COUNT_KEY, conf.getInt(HConstants.REGION_SERVER_HANDLER_COUNT, From 7b8f45c0f3031be48d0a6d76ba598d982ed071e3 Mon Sep 17 00:00:00 2001 From: teamconfx Date: Mon, 11 Sep 2023 22:53:41 +0800 Subject: [PATCH 2/4] add warning message if user choose to always allocated byte buffer from the pool --- .../java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java index 02d3fcba434a..a3018e655674 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java @@ -180,6 +180,10 @@ public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnab conf.getInt(MAX_BUFFER_COUNT_KEY, conf.getInt(HConstants.REGION_SERVER_HANDLER_COUNT, HConstants.DEFAULT_REGION_SERVER_HANDLER_COUNT) * bufsForTwoMB * 2); int minSizeForReservoirUse = conf.getInt(MIN_ALLOCATE_SIZE_KEY, poolBufSize / 6); + if (minSizeForReservoirUse == 0) { + LOG.warn("The minimal size for reservoir use is set to zero so that all allocations " + + "will be from the pool. Set a higher " + MIN_ALLOCATE_SIZE_KEY + " to avoid this."); + } Class clazz = conf.getClass(BYTEBUFF_ALLOCATOR_CLASS, ByteBuffAllocator.class); return (ByteBuffAllocator) ReflectionUtils.newInstance(clazz, true, maxBuffCount, poolBufSize, minSizeForReservoirUse); From 65e7709950c8eca7801ea6456798cb6b173ce9d2 Mon Sep 17 00:00:00 2001 From: teamconfx Date: Mon, 11 Sep 2023 23:49:33 +0800 Subject: [PATCH 3/4] use spotless apply to fix the style error --- .../org/apache/hadoop/hbase/io/ByteBuffAllocator.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java index a3018e655674..e5ce935cebab 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java @@ -172,8 +172,8 @@ public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnab // released the BBs it used, the handler might have processed one more read req. On an avg 2x // we consider and consider that also for the max buffers to pool if (poolBufSize <= 0) { - throw new IllegalArgumentException(BUFFER_SIZE_KEY + " must be positive. Please disable " + - "the reservoir rather than setting the size of the buffer to zero or negative."); + throw new IllegalArgumentException(BUFFER_SIZE_KEY + " must be positive. Please disable " + + "the reservoir rather than setting the size of the buffer to zero or negative."); } int bufsForTwoMB = (2 * 1024 * 1024) / poolBufSize; int maxBuffCount = @@ -181,8 +181,8 @@ public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnab HConstants.DEFAULT_REGION_SERVER_HANDLER_COUNT) * bufsForTwoMB * 2); int minSizeForReservoirUse = conf.getInt(MIN_ALLOCATE_SIZE_KEY, poolBufSize / 6); if (minSizeForReservoirUse == 0) { - LOG.warn("The minimal size for reservoir use is set to zero so that all allocations " + - "will be from the pool. Set a higher " + MIN_ALLOCATE_SIZE_KEY + " to avoid this."); + LOG.warn("The minimal size for reservoir use is set to zero so that all allocations " + + "will be from the pool. Set a higher " + MIN_ALLOCATE_SIZE_KEY + " to avoid this."); } Class clazz = conf.getClass(BYTEBUFF_ALLOCATOR_CLASS, ByteBuffAllocator.class); return (ByteBuffAllocator) ReflectionUtils.newInstance(clazz, true, maxBuffCount, poolBufSize, From 6b334ee5f3a08f53e3cb675f4c0f74f70fb38348 Mon Sep 17 00:00:00 2001 From: teamconfx Date: Wed, 20 Mar 2024 16:35:47 -0500 Subject: [PATCH 4/4] check negative value for minSizeForReservoirUse --- .../java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java index e5ce935cebab..737d93207cbb 100644 --- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java +++ b/hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBuffAllocator.java @@ -180,8 +180,8 @@ public static ByteBuffAllocator create(Configuration conf, boolean reservoirEnab conf.getInt(MAX_BUFFER_COUNT_KEY, conf.getInt(HConstants.REGION_SERVER_HANDLER_COUNT, HConstants.DEFAULT_REGION_SERVER_HANDLER_COUNT) * bufsForTwoMB * 2); int minSizeForReservoirUse = conf.getInt(MIN_ALLOCATE_SIZE_KEY, poolBufSize / 6); - if (minSizeForReservoirUse == 0) { - LOG.warn("The minimal size for reservoir use is set to zero so that all allocations " + if (minSizeForReservoirUse <= 0) { + LOG.warn("The minimal size for reservoir use is less or equal to zero, all allocations " + "will be from the pool. Set a higher " + MIN_ALLOCATE_SIZE_KEY + " to avoid this."); } Class clazz = conf.getClass(BYTEBUFF_ALLOCATOR_CLASS, ByteBuffAllocator.class);