question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Deleting topics throws exception

See original GitHub issue

When running EmbeddedSingleNodeKafkaCluster#deleteTopicsAndWait, Exception occurs if topics exist, and topics aren’t deleted. Have confirmed this on 2 machines (Windows 8.1 and Windows 10, both using java version 1.8.0_181).

Exception:

Caused by: java.nio.file.AccessDeniedException: C:\Users\gwade\AppData\Local\Temp\junit6747789160683566966\junit5490786451417386230\topic-0 -> C:\Users\gwade\AppData\Local\Temp\junit6747789160683566966\junit5490786451417386230\topic-0.a3c80cfca5e740bd8c1be434d817af2c-delete
        at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
        at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
        at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:387)
        at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
        at java.nio.file.Files.move(Files.java:1395)
        at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:809)
        at kafka.log.Log$$anonfun$renameDir$1.apply$mcV$sp(Log.scala:728)
        at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:726)
        at kafka.log.Log$$anonfun$renameDir$1.apply(Log.scala:726)
        at kafka.log.Log.maybeHandleIOException(Log.scala:1927)
        at kafka.log.Log.renameDir(Log.scala:726)
        at kafka.log.LogManager.asyncDelete(LogManager.scala:842)
        at kafka.cluster.Partition$$anonfun$delete$1.apply(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.apply(ReplicaManager.scala:380)
        at kafka.server.ReplicaManager$$anonfun$stopReplicas$2.apply(ReplicaManager.scala:378)
        at scala.collection.Iterator$class.foreach(Iterator.scala:893)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1336)
        at scala.collection.IterableLike$class.foreach(IterableLike.scala:72)
        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.lang.Thread.run(Thread.java:748)
        Suppressed: java.nio.file.AccessDeniedException: C:\Users\gwade\AppData\Local\Temp\junit6747789160683566966\junit5490786451417386230\topic-0 -> C:\Users\gwade\AppData\Local\Temp\junit6747789160683566966\junit5490786451417386230\topic-0.a3c80cfca5e740bd8c1be434d817af2c-delete
                at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:83)
                at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
                at sun.nio.fs.WindowsFileCopy.move(WindowsFileCopy.java:301)
                at sun.nio.fs.WindowsFileSystemProvider.move(WindowsFileSystemProvider.java:287)
                at java.nio.file.Files.move(Files.java:1395)
                at org.apache.kafka.common.utils.Utils.atomicMoveWithFallback(Utils.java:806)
                ... 22 more

This is recreated by this test https://pastebin.com/Rt0uZjDk

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
raedbenzcommented, Apr 6, 2020

this issue hasn’t gone, wondering why is closed. can we reopen it plz…unlesss it is a duplicate. I am using Kafka 2.3.1 on Windows 10 1803.

1reaction
leopardycommented, Feb 19, 2020

Since it’s not cool to continue offering a Windows distribution and later cop out by saying, don’t use the Windows distribution, the following is what worked for me when deleting a topic:

C:\kafka_2.13-2.4.0>.\bin\windows\kafka-topics.bat --zookeeper localhost:2181 --delete --topic mytopic

Since this only marks it for deletion, I then rebooted machine, restarted zookeeper and kafka, and re-ran the app that I had originally used to create the topic with the topic I’m trying to get rid of now removed(don’t remember what order I did the steps in).

This worked for me one time but not others. In that case I had to go to C:\tmp and remove both zookeeper and kafka-logs, then do steps above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AccessDeniedException when deleting a topic on Windows ...
1- stop zookeeper & Kafka server, 2- then go to 'kafka-logs' folder , there you will see list of kafka topic folders, delete...
Read more >
[#KAFKA-5975] No response when deleting topics ... - Apache
When trying to delete topics using the KafkaAdminClient and the flag in server ... + public void testDeleteTopics() throws Exception {
Read more >
Manually delete Apache Kafka topics | by Sunny Srinidhi
If you don't get an error, it means that topic is not yet deleted. Now run the following two commands to delete the...
Read more >
Freeing Objects in Exceptions | Microsoft Learn
As written above, myPerson will not be deleted if an exception is thrown by SomeFunc . Execution jumps directly to the next outer...
Read more >
How Do I Solve the Problem that Kafka Topics Cannot ... - 华为云
How do I delete a Kafka topic if it fails to be deleted? ... UnsatisfiedLinkError: Permission denied" exception thrown while starting HBase shell?...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found