diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java index b243b0e356f..42702de5747 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/KeyValueHeap.java @@ -112,8 +112,8 @@ public class KeyValueHeap extends NonReversedNonLazyKeyValueScanner this.current = pollRealKV(); } else { KeyValueScanner topScanner = this.heap.peek(); - if (topScanner == null || - this.comparator.compare(kvNext, topScanner.peek()) >= 0) { + // no need to add current back to the heap if it is the only scanner left + if (topScanner != null && this.comparator.compare(kvNext, topScanner.peek()) >= 0) { this.heap.add(this.current); this.current = pollRealKV(); }