Description
When running the Kafka 0.8.2-Beta (Scala 2.10) on Windows, an attempt to delete the Topic throwed an error:
ERROR [KafkaApi-1] error when handling request Name: StopReplicaRequest; Version: 0; CorrelationId: 38; ClientId: ; DeletePartitions: true; ControllerId: 0; ControllerEpoch: 3; Partitions: [test,0] (kafka.server.KafkaApis)
kafka.common.KafkaStorageException: Delete of index 00000000000000000000.index failed.
at kafka.log.LogSegment.delete(LogSegment.scala:283)
at kafka.log.Log$$anonfun$delete$1.apply(Log.scala:608)
at kafka.log.Log$$anonfun$delete$1.apply(Log.scala:608)
at scala.collection.Iterator$class.foreach(Iterator.scala:727)
at scala.collection.AbstractIterator.foreach(Iterator.scala:1157)
at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
at kafka.log.Log.delete(Log.scala:608)
at kafka.log.LogManager.deleteLog(LogManager.scala:375)
at kafka.cluster.Partition$$anonfun$delete$1.apply$mcV$sp(Partition.scala:144)
at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:139)
at kafka.cluster.Partition$$anonfun$delete$1.apply(Partition.scala:139)
at kafka.utils.Utils$.inLock(Utils.scala:535)
at kafka.utils.Utils$.inWriteLock(Utils.scala:543)
at kafka.cluster.Partition.delete(Partition.scala:139)
at kafka.server.ReplicaManager.stopReplica(ReplicaManager.scala:158)
at kafka.server.ReplicaManager$$anonfun$stopReplicas$3.apply(ReplicaManager.scala:191)
at kafka.server.ReplicaManager$$anonfun$stopReplicas$3.apply(ReplicaManager.scala:190)
at scala.collection.immutable.Set$Set1.foreach(Set.scala:74)
at kafka.server.ReplicaManager.stopReplicas(ReplicaManager.scala:190)
at kafka.server.KafkaApis.handleStopReplicaRequest(KafkaApis.scala:96)
at kafka.server.KafkaApis.handle(KafkaApis.scala:59)
at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:59)
at java.lang.Thread.run(Thread.java:744)
When I have investigated the issue I figured out that the index file (in my environment it was C:\tmp\kafka-logs\00000000-0000-0000-0000-000000000014-0\00000000000000000000.index) was locked by the kafka process and the OS did not allow to delete that file.
I tried to fix the problem in source codes and when I added close() method call into LogSegment.delete(), the Topic deletion started to work.
I will add here (not sure how to upload the file during issue creation) a diff with the changes I have made so You can take a look on that whether it is reasonable or not. It would be perfect if it could make it into the product...
In the end I would like to say that on Linux the deletion works just fine...