junrao commented on code in PR #15141: URL: https://github.com/apache/kafka/pull/15141#discussion_r1516745251
########## core/src/main/scala/kafka/log/UnifiedLog.scala: ########## @@ -1510,10 +1510,21 @@ class UnifiedLog(@volatile var logStartOffset: Long, } } localLog.checkIfMemoryMappedBufferClosed() - // remove the segments for lookups - localLog.removeAndDeleteSegments(segmentsToDelete, asyncDelete = true, reason) - deleteProducerSnapshots(deletable, asyncDelete = true) - incrementStartOffset(localLog.segments.firstSegmentBaseOffset.getAsLong, LogStartOffsetIncrementReason.SegmentDeletion) + if (remoteLogEnabled()) { + /** + * See @link{https://issues.apache.org/jira/browse/KAFKA-16073} for the background of this fix + */ + val newLocalLogStartOffset = localLog.segments.higherSegment(deletable.last.baseOffset()).get().baseOffset() + incrementStartOffset(newLocalLogStartOffset, LogStartOffsetIncrementReason.SegmentDeletion) + // remove the segments for lookups + localLog.removeAndDeleteSegments(segmentsToDelete, asyncDelete = true, reason) + deleteProducerSnapshots(deletable, asyncDelete = true) + } else { + // remove the segments for lookups + localLog.removeAndDeleteSegments(segmentsToDelete, asyncDelete = true, reason) Review Comment: For consistency, if we increase localLogStartOffset first and then delete the segments, we should do the same for logStartOffset too. -- 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. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org