Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exception during topic deletion when Kafka is hosted in Docker in Windows

I host Kafka in Docker in Windows. Wurstmeister/Kafka docker image is used. Kafka data is stored in local Windows folder for persistency. Windows folder is mapped to Kafka docker image via Docker volumes. I can create topics, publish and consume messages. However when I try to delete topic I receive the following error:

 Error while deleting test-0 in dir /var/lib/kafka. (kafka.server.LogDirFailureChannel)
 java.io.IOException: Failed to rename log directory from /var/lib/kafka/test-0 to /var/lib/kafka/test-0.a81ff9700e4e4c3e8b20c6d949971b64-delete
 at kafka.log.LogManager.asyncDelete(LogManager.scala:671)
 at kafka.cluster.Partition.$anonfun$delete$1(Partition.scala:178)
 at kafka.utils.CoreUtils$.inLock(CoreUtils.scala:217)
 at kafka.utils.CoreUtils$.inWriteLock(CoreUtils.scala:225)
 at kafka.cluster.Partition.delete(Partition.scala:173)
 at kafka.server.ReplicaManager.stopReplica(ReplicaManager.scala:341)
 at kafka.server.ReplicaManager.$anonfun$stopReplicas$2(ReplicaManager.scala:373)
 at scala.collection.Iterator.foreach(Iterator.scala:929)
 at scala.collection.Iterator.foreach$(Iterator.scala:929)
 at scala.collection.AbstractIterator.foreach(Iterator.scala:1417)
 at scala.collection.IterableLike.foreach(IterableLike.scala:71)
 at scala.collection.IterableLike.foreach$(IterableLike.scala:70)
 at scala.collection.AbstractIterable.foreach(Iterable.scala:54)
 at kafka.server.ReplicaManager.stopReplicas(ReplicaManager.scala:371)
 at kafka.server.KafkaApis.handleStopReplicaRequest(KafkaApis.scala:190)
 at kafka.server.KafkaApis.handle(KafkaApis.scala:104)
 at kafka.server.KafkaRequestHandler.run(KafkaRequestHandler.scala:65)
 at java.lang.Thread.run(Thread.java:748)

Could somebody help me to cope with this issue?

UPD: Below you can find contents of docker-compose file that I use to run Kafka:

version: '3'
services:
  zookeeper:
    image: zookeeper
    ports:
      - "2181:2181"
    environment:
      ZOO_MY_ID: 1
    volumes:
      - ./zookeeper_data:/data
      - ./zookeeper_datalog:/datalog
  kafka:
    depends_on: 
      - zookeeper
    image: wurstmeister/kafka
    ports:
      - "9092:9092"
    environment:
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ADVERTISED_HOST_NAME: localhost
      KAFKA_LOG_DIRS: /var/lib/kafka
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
      KAFKA_BROKER_ID: 1
    volumes:
      - ./kafka_logs:/var/lib/kafka
like image 534
Oleksandr Galperin Avatar asked Jan 05 '18 12:01

Oleksandr Galperin


People also ask

Is it possible to delete a kafka topic when the broker is down?

As you may have noticed, kafka-topics.sh --delete will only delete a topic if the topic's leader broker is available (and can acknowledge the removal). Since the broker 100 is down and currently unavailable the topic deletion has only been recorded in Zookeeper.

How do you enable delete topic enable in kafka?

You have to set delete. topic. enable to true in config/server. properties before issuing this delete-topic command, otherwise, Kafka ignores the command you submit and does nothing for the topic.


1 Answers

This issue still exists in Windows for Kafka ver 1.1.0 (kafka_2.12-1.1.0) when I try to delete the topic.

The topic gets marked for deletion and the Kafka server fails with java.nio.file.AccessDeniedException when trying to rename the logs directory 'test-0'

Deleting the whole test-0 logs folder does not help. Reinstalling the Kafka server does not help either - even after reinstalling, the info about the topic marked for deletion remains.

Took me a couple of hours to figure out that the info about the topic sits in the Zookeeper - in one of the log files!

Solution

Stop the Zookeeper process. Go to your Zookeeper logs folder zookeeper-3.x.x\bin\zookeeper-3.x.xdata\version-2\ and delete the latest log.xx files. Restart Zookeper. Restart Kafka server.

like image 196
Zee Man Avatar answered Oct 16 '22 16:10

Zee Man