From cdbef4990c1f386cd3be6569f4e8bea76dbf2a73 Mon Sep 17 00:00:00 2001 From: Ddupg Date: Thu, 1 Sep 2022 19:19:28 +0800 Subject: [PATCH] HBASE-27354 EOF thrown by WALEntryStream causes replication blocking --- .../replication/regionserver/WALEntryStream.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStream.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStream.java index 1d9f868e52fd..3337ad1fe6ea 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStream.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStream.java @@ -255,15 +255,21 @@ private void dequeueCurrentLog() throws IOException { * Returns whether the file is opened for writing. */ private boolean readNextEntryAndRecordReaderPosition() throws IOException { + long prePos = reader.getPosition(); + OptionalLong fileLength = walFileLengthProvider.getLogFileSizeIfBeingWritten(currentPath); + if (fileLength.isPresent() && prePos == fileLength.getAsLong()) { + LOG.debug("The provider tells us the valid length for {} is {}, we have advanced the end", + currentPath, fileLength.getAsLong()); + return true; + } Entry readEntry = reader.next(); long readerPos = reader.getPosition(); - OptionalLong fileLength = walFileLengthProvider.getLogFileSizeIfBeingWritten(currentPath); if (fileLength.isPresent() && readerPos > fileLength.getAsLong()) { // See HBASE-14004, for AsyncFSWAL which uses fan-out, it is possible that we read uncommitted // data, so we need to make sure that we do not read beyond the committed file length. if (LOG.isDebugEnabled()) { - LOG.debug("The provider tells us the valid length for " + currentPath + " is " - + fileLength.getAsLong() + ", but we have advanced to " + readerPos); + LOG.debug("The provider tells us the valid length for {} is {}, but we have advanced to {}", + currentPath, fileLength.getAsLong(), readerPos); } resetReader(); return true;