You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by zh...@apache.org on 2023/08/26 14:30:26 UTC

[hbase] branch HBASE-28028 updated (d323a90c988 -> 191da106666)

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

zhangduo pushed a change to branch HBASE-28028
in repository https://gitbox.apache.org/repos/asf/hbase.git


    omit d323a90c988 fix spotless
    omit 5e5c210bf85 HBASE-28028 Read all compressed bytes to a byte array before submitting them to decompressor
     add 8ccb910fa93 HBASE-27947 RegionServer OOM when outbound channel backed up (#5350)
     add dae078e5bc3 HBASE-28025 Enhance ByteBufferUtils.findCommonPrefix to compare 8 bytes each time (#5354)
     add 3f2e6555773 HBASE-28032 Fix ChaosMonkey documentation code block rendering (#5359)
     add d309e99f0ab HBASE-27966 HBase Master/RS JVM metrics populated incorrectly (#5323)
     add 94ed6add066 HBASE-28004 Persistent cache map can get corrupt if crash happens midway through the write (#5341)
     add 89ca7f4ade8 HBASE-28010 Connection attributes can become corrupted on the server side (#5366)
     new 191da106666 HBASE-28028 Read all compressed bytes to a byte array before submitting them to decompressor

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (d323a90c988)
            \
             N -- N -- N   refs/heads/HBASE-28028 (191da106666)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 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:
 .../apache/hadoop/hbase/util/ByteBufferUtils.java  | 185 +++++++++++++++---
 .../java/org/apache/hadoop/hbase/util/Bytes.java   | 107 ++++++++++-
 .../apache/hadoop/hbase/util/NettyUnsafeUtils.java |  61 ++++++
 .../hadoop/hbase/util/TestByteBufferUtils.java     |  31 +++
 .../org/apache/hadoop/hbase/util/TestBytes.java    |  43 +++++
 .../hadoop/hbase/ipc/MetricsHBaseServerSource.java |  16 ++
 .../hbase/ipc/MetricsHBaseServerSourceImpl.java    |  24 +++
 .../hbase/ipc/MetricsHBaseServerWrapper.java       |   7 +
 .../main/protobuf/server/io/BucketCacheEntry.proto |   3 +
 .../java/org/apache/hadoop/hbase/io/MetricsIO.java |  21 +-
 .../apache/hadoop/hbase/io/hfile/CacheConfig.java  |   2 -
 .../org/apache/hadoop/hbase/io/hfile/HFile.java    |  10 +-
 .../hadoop/hbase/io/hfile/HFilePreadReader.java    |  41 +++-
 .../hadoop/hbase/io/hfile/PrefetchExecutor.java    |  89 +--------
 .../hadoop/hbase/io/hfile/bucket/BucketCache.java  | 167 ++++++++++++----
 .../hadoop/hbase/io/hfile/bucket/BucketEntry.java  |  28 ++-
 .../hbase/io/hfile/bucket/BucketProtoUtils.java    |  10 +-
 .../hadoop/hbase/io/hfile/bucket/FileIOEngine.java |  37 +++-
 .../hadoop/hbase/ipc/MetricsHBaseServer.java       |   8 +
 .../hbase/ipc/MetricsHBaseServerWrapperImpl.java   |  13 ++
 .../apache/hadoop/hbase/ipc/NettyRpcServer.java    | 161 +++++++++++++++-
 .../NettyRpcServerChannelWritabilityHandler.java   | 125 ++++++++++++
 .../hbase/ipc/NettyRpcServerPreambleHandler.java   |  11 +-
 .../apache/hadoop/hbase/ipc/NettyServerCall.java   |   2 +-
 .../java/org/apache/hadoop/hbase/ipc/RpcCall.java  |  16 +-
 .../org/apache/hadoop/hbase/ipc/ServerCall.java    |  27 ++-
 .../hadoop/hbase/ipc/ServerRpcConnection.java      |  18 ++
 .../hbase/regionserver/wal/CompressionContext.java |   5 +-
 ...LDecompressionBoundedDelegatingInputStream.java |   7 +-
 .../client/TestRequestAndConnectionAttributes.java |  38 ++--
 .../hfile/TestBlockEvictionOnRegionMovement.java   |   1 -
 .../hadoop/hbase/io/hfile/TestPrefetchRSClose.java |   4 -
 .../io/hfile/TestPrefetchWithBucketCache.java      | 211 +++++++++++++++++++++
 .../hbase/io/hfile/bucket/TestBucketCache.java     |  84 +++++---
 .../io/hfile/bucket/TestBucketCachePersister.java  |   9 +-
 .../io/hfile/bucket/TestByteBufferIOEngine.java    |   2 +-
 .../io/hfile/bucket/TestPrefetchPersistence.java   |   9 +-
 .../hadoop/hbase/io/hfile/bucket/TestRAMCache.java |   2 +-
 .../io/hfile/bucket/TestVerifyBucketCacheFile.java | 102 ++++++++--
 .../hadoop/hbase/ipc/FailingNettyRpcServer.java    |   9 +-
 .../hbase/ipc/MetricsHBaseServerWrapperStub.java   |   7 +
 .../hbase/ipc/TestNettyChannelWritability.java     | 182 ++++++++++++++++++
 .../apache/hadoop/hbase/ipc/TestRpcMetrics.java    |   9 +
 .../hbase/ipc/TestRpcSkipInitialSaslHandshake.java |  28 +--
 .../hbase/namequeues/TestNamedQueueRecorder.java   |   8 +-
 .../store/region/TestRegionProcedureStore.java     |   8 +-
 .../hadoop/hbase/regionserver/TestMetricsJvm.java  | 113 +++++++++++
 src/main/asciidoc/_chapters/developer.adoc         |  40 +++-
 48 files changed, 1812 insertions(+), 329 deletions(-)
 create mode 100644 hbase-common/src/main/java/org/apache/hadoop/hbase/util/NettyUnsafeUtils.java
 create mode 100644 hbase-server/src/main/java/org/apache/hadoop/hbase/ipc/NettyRpcServerChannelWritabilityHandler.java
 create mode 100644 hbase-server/src/test/java/org/apache/hadoop/hbase/io/hfile/TestPrefetchWithBucketCache.java
 create mode 100644 hbase-server/src/test/java/org/apache/hadoop/hbase/ipc/TestNettyChannelWritability.java
 create mode 100644 hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestMetricsJvm.java


[hbase] 01/01: HBASE-28028 Read all compressed bytes to a byte array before submitting them to decompressor

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

zhangduo pushed a commit to branch HBASE-28028
in repository https://gitbox.apache.org/repos/asf/hbase.git

commit 191da10666619ecd01b2f1af3e060dffd9e5aea7
Author: Duo Zhang <zh...@apache.org>
AuthorDate: Thu Aug 17 22:54:19 2023 +0800

    HBASE-28028 Read all compressed bytes to a byte array before submitting them to decompressor
---
 .../hbase/regionserver/wal/CompressionContext.java |  9 +--
 ...LDecompressionBoundedDelegatingInputStream.java | 73 ++++++++++------------
 2 files changed, 36 insertions(+), 46 deletions(-)

diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/CompressionContext.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/CompressionContext.java
index 73cf4821db0..633decab0a8 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/CompressionContext.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/CompressionContext.java
@@ -28,7 +28,6 @@ import java.util.Map;
 import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseInterfaceAudience;
-import org.apache.hadoop.hbase.io.BoundedDelegatingInputStream;
 import org.apache.hadoop.hbase.io.TagCompressionContext;
 import org.apache.hadoop.hbase.io.compress.Compression;
 import org.apache.hadoop.hbase.io.util.Dictionary;
@@ -77,7 +76,7 @@ public class CompressionContext {
     private final Compression.Algorithm algorithm;
     private Compressor compressor;
     private Decompressor decompressor;
-    private BoundedDelegatingInputStream lowerIn;
+    private WALDecompressionBoundedDelegatingInputStream lowerIn;
     private ByteArrayOutputStream lowerOut;
     private InputStream compressedIn;
     private OutputStream compressedOut;
@@ -108,20 +107,17 @@ public class CompressionContext {
 
     public void decompress(InputStream in, int inLength, byte[] outArray, int outOffset,
       int outLength) throws IOException {
-
       // Our input is a sequence of bounded byte ranges (call them segments), with
       // BoundedDelegatingInputStream providing a way to switch in a new segment when the
       // previous segment has been fully consumed.
 
       // Create the input streams here the first time around.
       if (compressedIn == null) {
-        lowerIn = new BoundedDelegatingInputStream(in, inLength);
+        lowerIn = new WALDecompressionBoundedDelegatingInputStream();
         if (decompressor == null) {
           decompressor = algorithm.getDecompressor();
         }
         compressedIn = algorithm.createDecompressionStream(lowerIn, decompressor, IO_BUFFER_SIZE);
-      } else {
-        lowerIn.setDelegate(in, inLength);
       }
       if (outLength == 0) {
         // The BufferedInputStream will return earlier and skip reading anything if outLength == 0,
@@ -131,6 +127,7 @@ public class CompressionContext {
         // such as data loss when splitting wal or replicating wal.
         IOUtils.skipFully(in, inLength);
       } else {
+        lowerIn.reset(in, inLength);
         IOUtils.readFully(compressedIn, outArray, outOffset, outLength);
       }
     }
diff --git a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedDelegatingInputStream.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALDecompressionBoundedDelegatingInputStream.java
similarity index 57%
rename from hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedDelegatingInputStream.java
rename to hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALDecompressionBoundedDelegatingInputStream.java
index 2a6db09050c..0f4fd78a0b8 100644
--- a/hbase-common/src/main/java/org/apache/hadoop/hbase/io/BoundedDelegatingInputStream.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALDecompressionBoundedDelegatingInputStream.java
@@ -15,75 +15,73 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.hadoop.hbase.io;
+package org.apache.hadoop.hbase.regionserver.wal;
 
+import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
+import org.apache.commons.io.IOUtils;
 import org.apache.yetus.audience.InterfaceAudience;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
- * This is a stream that will only supply bytes from its delegate up to a certain limit. When there
- * is an attempt to set the position beyond that it will signal that the input is finished.
+ * This class is only used by WAL ValueCompressor for decompression.
+ * <p>
+ * <strong>WARNING: </strong>The implementation is very tricky and does not follow typical
+ * InputStream pattern, so do not use it in any other places.
  */
 @InterfaceAudience.Private
-public class BoundedDelegatingInputStream extends DelegatingInputStream {
+class WALDecompressionBoundedDelegatingInputStream extends InputStream {
 
-  protected long limit;
-  protected long pos;
+  private static final Logger LOG =
+    LoggerFactory.getLogger(WALDecompressionBoundedDelegatingInputStream.class);
 
-  public BoundedDelegatingInputStream(InputStream in, long limit) {
-    super(in);
-    this.limit = limit;
-    this.pos = 0;
-  }
+  private InputStream in;
+
+  private long pos;
 
-  public void setDelegate(InputStream in, long limit) {
+  private long limit;
+
+  public void reset(InputStream in, long limit) {
     this.in = in;
     this.limit = limit;
     this.pos = 0;
   }
 
-  /**
-   * Call the delegate's {@code read()} method if the current position is less than the limit.
-   * @return the byte read or -1 if the end of stream or the limit has been reached.
-   */
   @Override
   public int read() throws IOException {
     if (pos >= limit) {
       return -1;
     }
     int result = in.read();
+    if (result < 0) {
+      return -1;
+    }
     pos++;
     return result;
   }
 
-  /**
-   * Call the delegate's {@code read(byte[], int, int)} method if the current position is less than
-   * the limit.
-   * @param b   read buffer
-   * @param off Start offset
-   * @param len The number of bytes to read
-   * @return the number of bytes read or -1 if the end of stream or the limit has been reached.
-   */
   @Override
-  public int read(final byte[] b, final int off, final int len) throws IOException {
+  public int read(byte[] b, int off, int len) throws IOException {
     if (pos >= limit) {
       return -1;
     }
-    long readLen = Math.min(len, limit - pos);
-    int read = in.read(b, off, (int) readLen);
-    if (read < 0) {
+    int readLen = (int) Math.min(len, limit - pos);
+    try {
+      IOUtils.readFully(in, b, off, readLen);
+    } catch (EOFException e) {
+      // This is trick here, we will always try to read enough bytes to fill the buffer passed in,
+      // or we reach the end of this compression block, if there are not enough bytes, we just
+      // return -1 to let the upper layer fail with EOF
+      // In WAL value decompression this is OK as if we can not read all the data, we will finally
+      // get an EOF somewhere
+      LOG.debug("Got EOF while we want to read {} bytes from stream", readLen, e);
       return -1;
     }
-    pos += read;
-    return read;
+    return readLen;
   }
 
-  /**
-   * Call the delegate's {@code skip(long)} method.
-   * @param len the number of bytes to skip
-   * @return the actual number of bytes skipped
-   */
   @Override
   public long skip(final long len) throws IOException {
     long skipped = in.skip(Math.min(len, limit - pos));
@@ -91,10 +89,6 @@ public class BoundedDelegatingInputStream extends DelegatingInputStream {
     return skipped;
   }
 
-  /**
-   * @return the remaining bytes within the bound if the current position is less than the limit, or
-   *         0 otherwise.
-   */
   @Override
   public int available() throws IOException {
     if (pos >= limit) {
@@ -108,5 +102,4 @@ public class BoundedDelegatingInputStream extends DelegatingInputStream {
     // successful decompression depends on this behavior.
     return (int) (limit - pos);
   }
-
 }