diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncFSWAL.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncFSWAL.java index b2ebdb024e0a..483eb67d90bd 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncFSWAL.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncFSWAL.java @@ -438,7 +438,11 @@ private void appendAndSync() { newHighestProcessedAppendTxid = entry.getTxid(); iter.remove(); if (appended) { - unackedAppends.addLast(entry); + // This is possible, when we fail to sync, we will add the unackedAppends back to + // toWriteAppends, so here we may get an entry which is already in the unackedAppends. + if (unackedAppends.isEmpty() || unackedAppends.peekLast().getTxid() < entry.getTxid()) { + unackedAppends.addLast(entry); + } if (writer.getLength() - fileLengthAtLastSync >= batchSize) { break; }