Skip to content

Commit

Permalink
suppress java.nio.file.NoSuchFileException when renaming deleted segm…
Browse files Browse the repository at this point in the history
…ents (#419)

NoSuchFileException is-a IOException and Kafka handles it similar to a failure of the disk device and marks the log dir as offline due to a previous IO exception. However, this behavior is overly pessimistic and should be suppressed.
  • Loading branch information
sutambe authored Nov 22, 2022
1 parent fb7f981 commit 494cb74
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion core/src/main/scala/kafka/log/Log.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand Down

0 comments on commit 494cb74

Please sign in to comment.