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

KafkaConsumer seek methods should throw an exception when called for partitions not assigned to this consumer instance

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Invalid
    • None
    • 0.9.0.0
    • consumer
    • None

    Description

      It looks like the current code for the consumer will blindly accept any seek calls, adding the offests to SubscriptionState. If the consumer is being used in simple consumer mode, this makes sense, but when using subscriptions & the consumer coordinator, this should be an error.

      If a user accidentally invokes the seek at the wrong time, it will just get lost. As a simple example, if you start the consumer, subscribe, and then immediately seek, that seek will just get lost as soon as you call poll() and the initial join group + rebalance occurs. That sequence of calls simply shouldn't be valid since it doesn't make sense to seek() on a partition you haven't been assigned.

      Relatedly, I think the current effect of doing this can result in incorrect behavior because SubscriptionState.hasAllFetchedPositions() only checks the size of the fetched map and assignedPartitions map. Since this bug allows adding arbitrary topic partitions to the fetched map, that check is not accurate.

      This is probably related to KAFKA-2343, but that one is just a doc fix on how seek is supposed to behave wrt poll and rebalance.

      Attachments

        Activity

          People

            nehanarkhede Neha Narkhede
            ewencp Ewen Cheslack-Postava
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: