Skip to content

Commit e8f2fb8

Browse files
committed
KAFKA-19474: Move WARN log on log truncation below HWM
Moves the check for `offsetTruncationState.offset < log.highWatermark` before truncating the log as truncation might update the HWM thereby leading to an incorrect condition evaluation.
1 parent 860853d commit e8f2fb8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/main/scala/kafka/server/ReplicaFetcherThread.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,12 @@ class ReplicaFetcherThread(name: String,
166166
val partition = replicaMgr.getPartitionOrException(tp)
167167
val log = partition.localLogOrException
168168

169-
partition.truncateTo(offsetTruncationState.offset, isFuture = false)
170-
171169
if (offsetTruncationState.offset < log.highWatermark)
172170
warn(s"Truncating $tp to offset ${offsetTruncationState.offset} below high watermark " +
173171
s"${log.highWatermark}")
174172

173+
partition.truncateTo(offsetTruncationState.offset, isFuture = false)
174+
175175
// mark the future replica for truncation only when we do last truncation
176176
if (offsetTruncationState.truncationCompleted)
177177
replicaMgr.replicaAlterLogDirsManager.markPartitionsForTruncation(brokerConfig.brokerId, tp,

0 commit comments

Comments
 (0)