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

[bookkeeper] branch master updated: if entrySize > segmentSize , will throw IndexOutOfBoundsException when put entry into ReadCache (#2982)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 3f30d22  if entrySize > segmentSize ,will throw IndexOutOfBoundsException when put entry into ReadCache (#2982)
3f30d22 is described below

commit 3f30d22a185a775fac6fe10da2c1f12e4f7e4005
Author: chenlin <15...@qq.com>
AuthorDate: Thu Jan 13 01:45:04 2022 +0800

    if entrySize > segmentSize ,will throw IndexOutOfBoundsException when put entry into ReadCache (#2982)
---
 .../java/org/apache/bookkeeper/bookie/storage/ldb/ReadCache.java   | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/ReadCache.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/ReadCache.java
index 803666b..3ec4e11 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/ReadCache.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/storage/ldb/ReadCache.java
@@ -34,6 +34,8 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
 
 import org.apache.bookkeeper.util.collections.ConcurrentLongLongPairHashMap;
 import org.apache.bookkeeper.util.collections.ConcurrentLongLongPairHashMap.LongPair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Read cache implementation.
@@ -46,6 +48,7 @@ import org.apache.bookkeeper.util.collections.ConcurrentLongLongPairHashMap.Long
  * the read cache.
  */
 public class ReadCache implements Closeable {
+    private static final Logger log = LoggerFactory.getLogger(ReadCache.class);
 
     private static final int DEFAULT_MAX_SEGMENT_SIZE = 1 * 1024 * 1024 * 1024;
 
@@ -90,6 +93,10 @@ public class ReadCache implements Closeable {
         lock.readLock().lock();
 
         try {
+            if (entrySize > segmentSize) {
+                log.warn("entrySize {} > segmentSize {}, skip update read cache!", entrySize, segmentSize);
+                return;
+            }
             int offset = currentSegmentOffset.getAndAdd(alignedSize);
             if (offset + entrySize > segmentSize) {
                 // Roll-over the segment (outside the read-lock)