Repository navigation
Conversation
Both scenarios have the race fixed for spring-kafka-2.3.x-scenario in #841. The consumer has no committed offset and starts from the latest offset, while healthCheck reported success as soon as Tomcat started. When the entry request sent "helloWorld" before the consumer got its partition, the consumer skipped it, the request waited forever on the latch and its segment was never reported (SegmentNotFoundException for GET:/case/spring-kafka-case). Report healthy only after partitions are assigned. With auto commit disabled, the container resolves and commits the position of every assigned partition before it calls this listener, so a message sent after the health check passes is always consumed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the consumer race in spring-kafka-1.3.x and 2.2.x scenarios
Follow-up to #841, which fixed this race in
spring-kafka-2.3.x-scenario. The 1.3.x and 2.2.x scenarios have the same code, so they have the same latent race. They still pass in CI only because they usually win it.Cause
healthCheckreturned 200 as soon as Tomcat started.helloWorldbefore the consumer got its partition, the consumer skipped the message. The request then waited forever on the latch, so its segment was never reported (SegmentNotFoundExceptionforGET:/case/spring-kafka-case).Fix
healthCheckreports healthy only after aConsumerRebalanceListenersees a non-empty assignment, the same as the 2.3.x fix.consumer.position()and commits for every assigned partition before it calls the user listener. I checked this in the bytecode of 1.3.9, 1.3.10, 1.3.11 and 2.2.14.Verification
support-version.listfiles locally against a fresh Kafka 2.4.1 broker, with the mock collector, the agent and the validator.group.initial.rebalance.delay.msstands in for a slow runner.main's controller, 15s delayAt the broker's default 3s delay,
main's controller failed once in two 1.3.11 runs. The health check now returns 500 until the assignment, about 3s or 15s.This changes only test scenarios; there is no plugin or
CHANGES.mdchange.