diff --git a/core/src/main/scala/kafka/log/Log.scala b/core/src/main/scala/kafka/log/Log.scala index ed2ac0894b65a..dce4a2ab4d244 100644 --- a/core/src/main/scala/kafka/log/Log.scala +++ b/core/src/main/scala/kafka/log/Log.scala @@ -2682,7 +2682,15 @@ object Log extends Logging { logDirFailureChannel: LogDirFailureChannel, producerStateManager: ProducerStateManager, logPrefix: String): Unit = { - segmentsToDelete.foreach(_.changeFileSuffixes("", Log.DeletedFileSuffix)) + segmentsToDelete.foreach(logSegment => { + try { + logSegment.changeFileSuffixes("", Log.DeletedFileSuffix) + } catch { + case e: java.nio.file.NoSuchFileException => { + info(s"Failed to rename log file ${logSegment.log.file.getAbsoluteFile} with ${Log.DeletedFileSuffix} suffix because it was already deleted") + } + } + }) val snapshotsToDelete = if (deleteProducerStateSnapshots) segmentsToDelete.flatMap { segment => producerStateManager.removeAndMarkSnapshotForDeletion(segment.baseOffset)}