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

Duplicated consumption during rebalance, causing OffsetValidationTest to act flaky

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments



      Several flaky tests under OffsetValidationTest are indicating potential consumer duplication issue, when autocommit is enabled.  I believe this is affecting 3.2 and onward.  Below shows the failure message:


      Total consumed records 3366 did not match consumed position 3331 


      After investigating the log, I discovered that the data consumed between the start of a rebalance event and the async commit was lost for those failing tests.  In the example below, the rebalance event kicks in at around 1662054846995 (first record), and the async commit of the offset 3739 is completed at around 1662054847015 (right before partitions_revoked).



      A few things to note here:

      1. Manually calling commitSync in the onPartitionsRevoke cb seems to alleviate the issue
      2. Setting includeMetadataInTimeout to false also seems to alleviate the issue.

      The above tries seems to suggest that contract between poll() and asyncCommit() is broken.  AFAIK, we implicitly uses poll() to ack the previously fetched data, and the consumer would (try to) commit these offsets in the current poll() loop.  However, it seems like as the poll continues to loop, the "acked" data isn't being committed.


      I believe this could be introduced in  KAFKA-14024, which originated from KAFKA-13310.

      More specifically, (see the comments below), the ConsumerCoordinator will alway return before async commit, due to the previous incomplete commit.  However, this is a bit contradictory here because:

      1. I think we want to commit asynchronously while the poll continues, and if we do that, we are back to KAFKA-14024, that the consumer will get rebalance timeout and get kicked out of the group.
      2. But we also need to commit all the "acked" offsets before revoking the partition, and this has to be blocked.

      Steps to Reproduce the Issue:

      1. Check out AK 3.2
      2. Run this several times: (Recommend to only run runs with autocommit enabled in consumer_test.py to save time)
        _DUCKTAPE_OPTIONS="--debug" TC_PATHS="tests/kafkatest/tests/client/consumer_test.py::OffsetValidationTest.test_consumer_failure" bash tests/docker/run_tests.sh 


      Steps to Diagnose the Issue:

      1. Open the test results in results/
      2. Go to the consumer log.  It might look like this



      3. Find the docker instance that has partition getting revoked and rejoined.  Observed the offset before and after.

      Propose Fixes:






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


            pnee Philip Nee
            pnee Philip Nee
            0 Vote for this issue
            5 Start watching this issue




                Issue deployment