You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2021/05/12 18:23:46 UTC
[hbase] branch branch-2.4 updated: HBASE-25876 Add retry if we fail
to read all bytes of the protobuf magic marker (#3251)
This is an automated email from the ASF dual-hosted git repository.
stack pushed a commit to branch branch-2.4
in repository https://gitbox.apache.org/repos/asf/hbase.git
The following commit(s) were added to refs/heads/branch-2.4 by this push:
new 1c829af HBASE-25876 Add retry if we fail to read all bytes of the protobuf magic marker (#3251)
1c829af is described below
commit 1c829af56a6b7485610dfbf44089cf7ae6415662
Author: Michael Stack <sa...@users.noreply.github.com>
AuthorDate: Wed May 12 13:20:50 2021 -0500
HBASE-25876 Add retry if we fail to read all bytes of the protobuf magic marker (#3251)
Signed-off-by: Duo Zhang <zh...@apache.org>
Signed-off-by Anoop Sam John <an...@apache.org>
---
.../src/main/java/org/apache/hadoop/hbase/HRegionInfo.java | 3 +--
.../java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java | 7 ++-----
2 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
index 6edd3fa..8754430 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HRegionInfo.java
@@ -964,8 +964,7 @@ public class HRegionInfo implements RegionInfo {
}
//assumption: if Writable serialization, it should be longer than pblen.
- int read = in.read(pbuf);
- if (read != pblen) throw new IOException("read=" + read + ", wanted=" + pblen);
+ in.readFully(pbuf, 0, pblen);
if (ProtobufUtil.isPBMagicPrefix(pbuf)) {
return convert(HBaseProtos.RegionInfo.parseDelimitedFrom(in));
} else {
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
index 1f9aac4..80f6833 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/io/hfile/bucket/BucketCache.java
@@ -49,6 +49,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Consumer;
+import org.apache.commons.io.IOUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
@@ -1067,11 +1068,7 @@ public class BucketCache implements BlockCache, HeapSize {
try (FileInputStream in = deleteFileOnClose(persistenceFile)) {
int pblen = ProtobufMagic.lengthOfPBMagic();
byte[] pbuf = new byte[pblen];
- int read = in.read(pbuf);
- if (read != pblen) {
- throw new IOException("Incorrect number of bytes read while checking for protobuf magic "
- + "number. Requested=" + pblen + ", Received= " + read + ", File=" + persistencePath);
- }
+ IOUtils.readFully(in, pbuf, 0, pblen);
if (! ProtobufMagic.isPBMagicPrefix(pbuf)) {
// In 3.0 we have enough flexibility to dump the old cache data.
// TODO: In 2.x line, this might need to be filled in to support reading the old format