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 8eec02a661e8..14e95852bdb9 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 @@ -343,11 +343,13 @@ private HasNext tryAdvanceEntry() { case EOF_WITH_TRAILER: // in readNextEntryAndRecordReaderPosition, we will acquire rollWriteLock, and we can only // schedule a close writer task, in which we will write trailer, under the rollWriteLock, so - // if beingWritten == true, it means that the reader is opened before writing the trailer, - // so we can not get a EOF_WITH_TRAILER return value while reading from this reader. - // this is very important for make sure that we will not consume the logQueue to empty for a - // normal replication queue - assert !beingWritten; + // typically if beingWritten == true, we should not reach here, as we need to reopen the + // reader after writing the trailer. The only possible way to reach here while beingWritten + // == true is due to the inflightWALClosures logic in AbstractFSWAL, as if the writer is + // still in this map, we will consider it as beingWritten, but actually, here we could make + // sure that the new WAL file has already been enqueued into the logQueue, so here dequeuing + // the current log file is safe. + assert beingWritten && logQueue.getQueue(walGroupId).size() > 1; // we have reached the trailer, which means this WAL file has been closed cleanly and we // have finished reading it successfully, just move to the next WAL file and let the upper // layer start reading the next WAL file