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

Log thread names & ids when KafkaConsumer throws ConcurrentModificationException

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: In Progress
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • consumer, logging
    • None

    Description

      KafkaConsumer does not support multi-threaded usage and any access by a thread that does not have the lock will cause ConcurrentModificationException to be thrown.

      For some users leveraging frameworks on top of Kafka that abstract the actual KafkaConsumer class/calls, it can be hard to identify user and/or framework bugs when this exception is thrown.

      It would be incredibly helpful to log both the thread name and the thread ID of the thread that has acquired the lock, and the current thread that is attempting to obtain the lock in the exception message.

       

      KafkaConsumer currently only tracks the id of the thread that has acquired the lock. Additionally, we should also keep track of the thread name.

      An example of the exception message: "KafkaConsumer is not safe for multi-threaded access: acquiredThreadName=acquiredThread, acquiredThreadId=1, currentThreadName=rejectedThread, currentThreadId=2"

      Attachments

        Activity

          People

            lu.kevin Kevin Lu
            lu.kevin Kevin Lu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: