Skip to content

Commit

Permalink
HBASE-25876 Add retry if we fail to read all bytes of the protobuf ma…
Browse files Browse the repository at this point in the history
…gic marker (#3251)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by Anoop Sam John <anoopsamjohn@apache.org>
(cherry picked from commit 0755457)
  • Loading branch information
saintstack authored and Apache9 committed Oct 26, 2024
1 parent 6b5cc5b commit 5d8ec4d
Showing 1 changed file with 2 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.function.Consumer;
import java.util.function.Function;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.mutable.MutableInt;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
Expand Down Expand Up @@ -1488,11 +1489,7 @@ private void retrieveFromFile(int[] bucketSizes) throws IOException {
try (FileInputStream in = new FileInputStream(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)) {
LOG.info("Reading old format of persistence.");
// The old non-chunked version of backing map persistence.
Expand Down

0 comments on commit 5d8ec4d

Please sign in to comment.