I am new in kafka using c#. It was working fine earlier. But now kafka server is crashing with following error.

Error : 
Error while renaming dir for 46_HAQ-0 in log dir D:\tmp\kafka-logs (kafka.server.LogDirFailureChannel)
java.nio.file.AccessDeniedException: D:\tmp\kafka-logs\46_HAQ-0 -> D:\tmp\kafka-logs\46_HAQ-0.e77858d11274489887d14b1b0407cd44-delete
        at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
        at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
        at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:395)
        at java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:288)
        at java.base/java.nio.file.Files.move(Files.java:1421)
        at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:809)
        at kafka.log.Log.$anonfun$renameDir$2(Log.scala:759)
        at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)
        at kafka.log.Log.maybeHandleIOException(Log.scala:1996)
        at kafka.log.Log.renameDir(Log.scala:757)
        at kafka.log.LogManager.asyncDelete(LogManager.scala:842)
        at kafka.cluster.Partition.$anonfun$delete$1(Partition.scala:353)
        at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:251)
        at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:259)
        at kafka.cluster.Partition.delete(Partition.scala:347)
        at kafka.server.ReplicaManager.stopReplica(ReplicaManager.scala:350)
        at kafka.server.ReplicaManager.$anonfun$stopReplicas$2(ReplicaManager.scala:380)
        at scala.collection.Iterator.foreach(Iterator.scala:937)
        at scala.collection.Iterator.foreach$(Iterator.scala:937)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1425)
        at scala.collection.IterableLike.foreach(IterableLike.scala:70)
        at scala.collection.IterableLike.foreach$(IterableLike.scala:69)
        at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
        at kafka.server.ReplicaManager.stopReplicas(ReplicaManager.scala:378)
        at kafka.server.KafkaApis.handleStopReplicaRequest(KafkaApis.scala:200)
        at kafka.server.KafkaApis.handle(KafkaApis.scala:111)
        at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:69)
        at java.base/java.lang.Thread.run(Thread.java:834)
        Suppressed: java.nio.file.AccessDeniedException: D:\tmp\kafka-logs\46_HAQ-0 -> D:\tmp\kafka-logs\46_HAQ-0.e77858d11274489887d14b1b0407cd44-delete
                at java.base/sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:89)
                at java.base/sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:103)
                at java.base/sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:309)
                at java.base/sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:288)
                at java.base/java.nio.file.Files.move(Files.java:1421)
                at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:806)


stopped moving logs for partitions  because they are in the failed log directory D:\tmp\kafka-logs. (kafka.server.ReplicaManager)
[2019-05-08 08:05:00,598] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions Set() (kafka.server.ReplicaFetcherManager)
[2019-05-08 08:05:00,598] INFO Stopping serving logs in dir D:\tmp\kafka-logs (kafka.log.LogManager)
[2019-05-08 08:05:00,601] INFO [ReplicaAlterLogDirsManager on broker 0] Removed fetcher for partitions Set() (kafka.server.ReplicaAlterLogDirsManager)
[2019-05-08 08:05:00,608] INFO [ReplicaFetcherManager on broker 0] Removed fetcher for partitions Set(46_HAQ-0) (kafka.server.ReplicaFetcherManager)
[2019-05-08 08:05:00,608] INFO [ReplicaAlterLogDirsManager on broker 0] Removed fetcher for partitions Set(46_HAQ-0) (kafka.server.ReplicaAlterLogDirsManager)
[2019-05-08 08:05:00,612] ERROR Shutdown broker because all log dirs in D:\tmp\kafka-logs have failed (kafka.log.LogManager.

I have encounter this problem multiple times.

1 Answers

0
Community On

What helped me to get rid of this problem is to delete both zookeeper data folder and kafka logs folder.

Here are these folders on my Windows machine:

1) My C:/(zookeeper-home-dir)/conf/zoo.cfg file has dataDir=C:\zookeeper-3.4.14\data setting which gets translated into creating this data folder on Zookeeper start-up: C:/(Zookeeper-home)/bin/zookeeper-3.4.14data

2) My C:/(kafka-home-dir)/config/server.properties file has log.dirs=C:\kafka_2.11-2.2.0\kafka-logs setting, so on Kafka start-up the following logs folder is created: C:/(Kafka-home)/kafka_2.11-2.2.0kafka-logs