From 683e3bd49750ea3106c02b8b110cd0fefd2868d5 Mon Sep 17 00:00:00 2001 From: haxiaolin Date: Tue, 20 Jun 2023 16:00:18 +0800 Subject: [PATCH] HBASE-27927 Skip zero length bytes of WALKey and WALEntry cells to avoid replication stuck with WAL compression --- .../hbase/regionserver/wal/ProtobufWALTailingReader.java | 4 +++- .../apache/hadoop/hbase/regionserver/wal/WALCellCodec.java | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufWALTailingReader.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufWALTailingReader.java index 62091acdd1db..6319ff296d66 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufWALTailingReader.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufWALTailingReader.java @@ -79,7 +79,9 @@ private IOException unwrapIPBE(IOException e) { private ReadWALKeyResult readWALKey(long originalPosition) { int firstByte; try { - firstByte = delegatingInput.read(); + do { + firstByte = delegatingInput.read(); + } while (firstByte == 0); } catch (IOException e) { LOG.warn("Failed to read wal key length first byte", e); return KEY_ERROR_AND_RESET; diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java index 84709cbc58dd..149b423ccb76 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/WALCellCodec.java @@ -288,6 +288,11 @@ public CompressedKvDecoder(InputStream in, CompressionContext compression) { @Override protected Cell parseCell() throws IOException { + int firstByte = in.read(); + while (firstByte == 0) { + firstByte = in.read(); + } + ((PBIS) in).unread(firstByte); int keylength = StreamUtils.readRawVarint32(in); int vlength = StreamUtils.readRawVarint32(in); int tagsLength = StreamUtils.readRawVarint32(in);