junrao commented on a change in pull request #10280: URL: https://github.com/apache/kafka/pull/10280#discussion_r648679167
########## File path: core/src/main/scala/kafka/log/Log.scala ########## @@ -1812,37 +1570,39 @@ class Log(@volatile private var _dir: File, endOffset: Long ): Unit = { logStartOffset = startOffset - nextOffsetMetadata = LogOffsetMetadata(endOffset, activeSegment.baseOffset, activeSegment.size) - recoveryPoint = math.min(recoveryPoint, endOffset) + localLog.updateLogEndOffset(endOffset) rebuildProducerState(endOffset, producerStateManager) - updateHighWatermark(math.min(highWatermark, endOffset)) + if (highWatermark < localLog.logEndOffset) Review comment: If highWatermark is smaller, there is no need to update high watermark. ########## File path: core/src/main/scala/kafka/log/Log.scala ########## @@ -1788,17 +1554,9 @@ class Log(@volatile private var _dir: File, maybeHandleIOException(s"Error while truncating the entire log for $topicPartition in dir ${dir.getParent}") { debug(s"Truncate and start at offset $newOffset") lock synchronized { - checkIfMemoryMappedBufferClosed() - removeAndDeleteSegments(logSegments, asyncDelete = true, LogTruncation) - addSegment(LogSegment.open(dir, - baseOffset = newOffset, - config = config, - time = time, - initFileSize = config.initFileSize, - preallocate = config.preallocate)) + localLog.truncateFullyAndStartAt(newOffset) Review comment: This is an existing issue. In this case, it seems that we should always update high watermark in completeTruncation() with localLog.logEndOffsetMetadata. -- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org