Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-14271

Topic recreation fails in KRaft mode when topic contains collidable characters

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Duplicate
    • 3.3.0
    • None
    • kraft
    • None

    Description

      We recently updated one of our clusters from 3.2.0 to 3.3.0 (primarily to get the fix forĀ KAFKA-13909). This cluster is running KRaft mode.

      This is a cluster used for some integration tests - each test deletes the topics it uses before the test to ensure a clean slate for the test; the brokers get restarted in-between tests, but the broker data isn't deleted.

      With 3.3.0, this semi-crashes Kafka. The brokers stay running, but the topic creation fails:

      [2022-09-30 17:17:59,216] WARN [Controller 1] createTopics: failed with unknown server exception NoSuchElementException at epoch 1 in 601 us.  Renouncing leadership and reverting to the last committed offset 18. (org.apache.kafka.controller.QuorumController)
      java.util.NoSuchElementException
              at org.apache.kafka.timeline.SnapshottableHashTable$CurrentIterator.next(SnapshottableHashTable.java:167)
              at org.apache.kafka.timeline.SnapshottableHashTable$CurrentIterator.next(SnapshottableHashTable.java:139)
              at org.apache.kafka.timeline.TimelineHashSet$ValueIterator.next(TimelineHashSet.java:120)
              at org.apache.kafka.controller.ReplicationControlManager.validateNewTopicNames(ReplicationControlManager.java:799)
              at org.apache.kafka.controller.ReplicationControlManager.createTopics(ReplicationControlManager.java:567)
              at org.apache.kafka.controller.QuorumController.lambda$createTopics$7(QuorumController.java:1832)
              at org.apache.kafka.controller.QuorumController$ControllerWriteEvent.run(QuorumController.java:767)
              at org.apache.kafka.queue.KafkaEventQueue$EventContext.run(KafkaEventQueue.java:121)
              at org.apache.kafka.queue.KafkaEventQueue$EventHandler.handleEvents(KafkaEventQueue.java:200)
              at org.apache.kafka.queue.KafkaEventQueue$EventHandler.run(KafkaEventQueue.java:173)
              at java.base/java.lang.Thread.run(Thread.java:829)
      

      This appears to be because our topic names contain .'s. Here's a quick reproducer script:

      #!/bin/bash
      
      VERSION=3.3.0
      TOPIC=$1
      
      set -x
      
      rm -rf -- kafka_2.13-${VERSION} kafka_2.13-${VERSION}.tgz /tmp/kraft-combined-logs
      trap 'kill -- "-$$" && wait' EXIT
      
      curl -O https://dlcdn.apache.org/kafka/$VERSION/kafka_2.13-${VERSION}.tgz
      
      tar -xzf kafka_2.13-${VERSION}.tgz
      
      cd kafka_2.13-${VERSION}
      
      id=$(./bin/kafka-storage.sh random-uuid)
      ./bin/kafka-storage.sh format -t $id -c ./config/kraft/server.properties
      
      ./bin/kafka-server-start.sh config/kraft/server.properties > broker.log 2>&1 &
      sleep 1
      
      ./bin/kafka-topics.sh --create --topic "$TOPIC" --bootstrap-server localhost:9092
      ./bin/kafka-topics.sh --delete --topic "$TOPIC" --bootstrap-server localhost:9092
      ./bin/kafka-topics.sh --create --topic "$TOPIC" --bootstrap-server localhost:9092
      sleep 1
      

      Running ./test-kafka.sh topic.with.dots exhibits the failure; using topicwithoutdots works as expected.

      I'll attach the broker logs from each run.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            jeffreytolar Jeffrey Tolar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment