Skip to content

KAFKA-21017: Deflake ConsumerGroupCommandSaslAuthenticationTest - #23154

Merged
AndrewJSchofield merged 2 commits into
apache:trunkfrom
stantheman0128:deflake/consumer-group-sasl-auth-test
Sep 10, 2026
Merged

AndrewJSchofield merged 2 commits into
apache:trunkfrom
stantheman0128:deflake/consumer-group-sasl-auth-test

Conversation

@stantheman0128

@stantheman0128 stantheman0128 commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

ClassicKafkaConsumer has no background thread, so poll() is what drives
JoinGroup and SyncGroup for the classic group protocol. In
testConsumerGroupServiceWithAuthenticationSuccess, the second
waitForCondition checked group visibility but never called poll() again.
If the handshake was not finished after the first successful poll,
nothing pushed it forward, and the test timed out under load.

Andrew asked to match ListConsumerGroupTest: an executor that keeps
polling until the consumer is closed. The success path now uses
ConsumerGroupCommandTestUtils.buildConsumers, so the classic consumer
keeps polling JoinGroup/SyncGroup on a background thread until the test
closes it. The two waitForCondition blocks stay separate so the
auth-failure and missing-group-visibility messages stay distinguishable.

Fixes KAFKA-21017.

Verified:

  • First poll() patch: class run 30 times (all green); 60 times reverted
    under a warm daemon (all green); 30 times reverted under artificial CPU
    load (4/30 red).
  • After the buildConsumers refactor I did not re-run the cluster test on
    this Windows box. dino2895 repeated
    testConsumerGroupServiceWithAuthenticationSuccessWithClassicGroupProtocol
    300 times with -Pkafka.cluster.test.repeat=300; all 300 passed.

Co-Authored-By: Claude Sonnet 5 [email protected]

Reviewers: Uros (github:uros-b), YANG-SYUAN CHOU [email protected],
Andrew Schofield [email protected]

…during group-visibility wait

ClassicKafkaConsumer has no background thread, so poll() is what drives JoinGroup and SyncGroup for the classic group protocol. In testConsumerGroupServiceWithAuthenticationSuccess, the second waitForCondition checked group visibility but never called poll() again. If the handshake wasn't finished after the first successful poll, nothing pushed it forward, and the test timed out under load.

This keeps the two waitForCondition blocks separate, so the auth-failure and missing-group-visibility messages stay distinguishable, and just adds poll() to the second one.

Verified with the test class run 30 times with the fix (all green), 60 times reverted under a warm daemon (all green, does not reproduce the flake), and 30 times reverted under artificial CPU load (4/30 red, matching the ~10% rate reported before this change).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions github-actions Bot added triage PRs from the community tools tests Test fixes (including flaky tests) small Small PRs labels Aug 13, 2026
@uros-b

uros-b commented Aug 15, 2026

Copy link
Copy Markdown
Member

LGTM

@github-actions github-actions Bot removed the triage PRs from the community label Aug 16, 2026

@AndrewJSchofield AndrewJSchofield left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I would prefer this to be refactored to use a similar pattern to ListConsumerGroupTest with an executor polling until the consumer is closed.

Use ConsumerGroupCommandTestUtils.buildConsumers like ListConsumerGroupTest so the classic protocol consumer keeps polling JoinGroup/SyncGroup on a background thread until the test closes it.

Signed-off-by: Stan Shih <[email protected]>
Co-authored-by: Cursor <[email protected]>
@stantheman0128

Copy link
Copy Markdown
Contributor Author

Thanks Andrew. I switched the success path to ConsumerGroupCommandTestUtils.buildConsumers, the same executor helper ListConsumerGroupTest uses, so the classic consumer keeps polling JoinGroup/SyncGroup on a background thread until the test closes it.

Pushed as 827a8a6. I did not re-run the cluster test on this box after the refactor (Windows load); happy to retrigger CI here.

@dino2895

dino2895 commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Hi @stantheman0128, KAFKA-21017 has been created for this flaky test, and I’m currently assigned to the issue.
Could you please update the PR title to:
KAFKA-21017: Deflake ConsumerGroupCommandSaslAuthenticationTest
It would also be helpful to update the PR description to reflect the latest implementation using ConsumerGroupCommandTestUtils.buildConsumers.

Also I verified the latest change locally by repeating testConsumerGroupServiceWithAuthenticationSuccessWithClassicGroupProtocol 300 times using
-Pkafka.cluster.test.repeat=300. All 300 invocations passed with 0 failures, errors, or skipped tests.

@stantheman0128 stantheman0128 changed the title MINOR: Deflake ConsumerGroupCommandSaslAuthenticationTest by polling during group-visibility wait KAFKA-21017: Deflake ConsumerGroupCommandSaslAuthenticationTest Sep 3, 2026
@stantheman0128

Copy link
Copy Markdown
Contributor Author

Thanks. Title and description now match KAFKA-21017 and the ConsumerGroupCommandTestUtils.buildConsumers path Andrew asked for.

I did not re-run the cluster test here after that refactor. Your 300 repeats of testConsumerGroupServiceWithAuthenticationSuccessWithClassicGroupProtocol with -Pkafka.cluster.test.repeat=300 are the coverage for the current head.

@AndrewJSchofield AndrewJSchofield left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@AndrewJSchofield
AndrewJSchofield merged commit 2618081 into apache:trunk Sep 10, 2026
24 checks passed
joshua2519 pushed a commit to joshua2519/kafka that referenced this pull request Sep 12, 2026
…he#23154)

ClassicKafkaConsumer has no background thread, so poll() is what drives
JoinGroup and SyncGroup for the classic group protocol. In
testConsumerGroupServiceWithAuthenticationSuccess, the second
waitForCondition checked group visibility but never called poll() again.
If the handshake was not finished after the first successful poll,
nothing pushed it forward, and the test timed out under load.

Andrew asked to match ListConsumerGroupTest: an executor that keeps
polling until the consumer is closed. The success path now uses
ConsumerGroupCommandTestUtils.buildConsumers, so the classic consumer
keeps polling JoinGroup/SyncGroup on a background thread until the test
closes it. The two waitForCondition blocks stay separate so the
auth-failure and missing-group-visibility messages stay distinguishable.

Fixes KAFKA-21017.

Verified:
- First poll() patch: class run 30 times (all green); 60 times reverted
under a warm daemon (all green); 30 times reverted under artificial CPU
load (4/30 red).
- After the buildConsumers refactor I did not re-run the cluster test on
this Windows box. dino2895 repeated

testConsumerGroupServiceWithAuthenticationSuccessWithClassicGroupProtocol
300 times with -Pkafka.cluster.test.repeat=300; all 300 passed.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

Reviewers: Uros (github:uros-b), YANG-SYUAN CHOU <[email protected]>,
Andrew Schofield <[email protected]>

---------

Signed-off-by: Stan Shih <[email protected]>
Co-authored-by: stantheman0128 <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
Co-authored-by: Cursor <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-approved small Small PRs tests Test fixes (including flaky tests) tools

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants