dengziming commented on a change in pull request #10021:
URL: https://github.com/apache/kafka/pull/10021#discussion_r582587511



##########
File path: core/src/main/scala/kafka/raft/KafkaMetadataLog.scala
##########
@@ -299,7 +290,16 @@ final class KafkaMetadataLog private (
       // If snapshotIds contains a snapshot id, the KafkaRaftClient and 
Listener can expect that the snapshot exists
       // on the file system, so we should first remove snapshotId and then 
delete snapshot file.
       expiredSnapshotIdsIter.remove()
-      Snapshots.deleteSnapshotIfExists(log.dir.toPath, snapshotId)
+
+      val path = Snapshots.snapshotPath(log.dir.toPath, snapshotId)
+      val destination = Snapshots.deleteRename(path, snapshotId)
+      try {
+        Utils.atomicMoveWithFallback(path, destination)
+      } catch {
+        case e: IOException =>
+          warn("Error renaming snapshot file: " + path + " to :" + destination 
+ ", " + e.getMessage)
+      }
+      scheduler.schedule("delete-snapshot-file", () => 
Snapshots.deleteSnapshotIfExists(log.dir.toPath, snapshotId))

Review comment:
       Done!




----------------------------------------------------------------
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


Reply via email to