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

Consumers balance fails when multiple consumers are started simultaneously.

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Auto Closed
    • Affects Version/s: 0.8.1.1, 0.8.2.1
    • Fix Version/s: None
    • Component/s: consumer
    • Labels:
    • Flags:
      Patch

      Description

      During consumer startup a race condition can occur if multiple consumers are started (nearly) simultaneously.

      If a second consumer is started while the first consumer is in the middle of zkClient.subscribeChildChanges the first consumer will never see the registration of the second consumer, because the consumer registration node for the second consumer will be unwatched, and no new child will be registered later. This causes the first consumer to own all partitions, and then never release ownership causing the second consumer to fail rebalancing.

      The attached patch solves this by using an "epoch" node which all consumers watch and update to trigger a rebalance. When a rebalance is triggered we check the consumer registrations against a cached state, to avoid unnecessary rebalances. For safety, we also periodically check the consumer registrations and rebalance. We have been using this patch in production at HubSpot for a while and it has eliminated all rebalance issues.

        Attachments

          Activity

            People

            • Assignee:
              zklapow Ze'ev Eli Klapow
              Reporter:
              zklapow Ze'ev Eli Klapow
              Reviewer:
              Guozhang Wang
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: