Apache9 commented on code in PR #5505:
URL: https://github.com/apache/hbase/pull/5505#discussion_r1382731051


##########
hbase-server/src/main/java/org/apache/hadoop/hbase/replication/regionserver/WALEntryStream.java:
##########
@@ -258,7 +258,26 @@ private void dequeueCurrentLog() throws IOException {
   private boolean readNextEntryAndRecordReaderPosition() throws IOException {
     Entry readEntry = reader.next();
     long readerPos = reader.getPosition();
-    OptionalLong fileLength = 
walFileLengthProvider.getLogFileSizeIfBeingWritten(currentPath);
+    OptionalLong fileLength;
+    if (logQueue.getQueueSize(walGroupId) > 1) {
+      // if there are more than one files in queue, although it is possible 
that we are
+      // still trying to write the trailer of the file and it is not closed 
yet, we can
+      // make sure that we will not write any WAL entries to it any more, so 
it is safe
+      // to just let the upper layer try to read the whole file without limit
+      fileLength = OptionalLong.empty();
+    } else {
+      // if there is only one file in queue, check whether it is still being 
written to
+      // we must call this before actually reading from the reader, as this 
method will acquire the

Review Comment:
   For branch-2.5, the way we deal with empty queue problem is different. As 
there is no comment before this PR, let's just add 'if there is only one file 
in queue, check whether it is still being written to' comment here. The 
comments below are for branch-2+, where we have refactored the code a lot.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to