KAFKA-20970 Another busy loop happens if auto.commit.interval.ms is less than bootstrap.resolve.timeout.ms - #23227
Open
m1a2st wants to merge 2 commits into
Open
KAFKA-20970 Another busy loop happens if auto.commit.interval.ms is less than bootstrap.resolve.timeout.ms#23227m1a2st wants to merge 2 commits into
m1a2st wants to merge 2 commits into
Conversation
Member
|
Might |
AndrewJSchofield
left a comment
Member
There was a problem hiding this comment.
Thanks for the PR. Looks good to me. Just one suggestion for the test.
| @Test | ||
| public void testMaximumTimeToWaitWhenCoordinatorUnknownDoesNotSpin() { | ||
| CommitRequestManager commitRequestManager = create(true, 100); | ||
|
|
Member
There was a problem hiding this comment.
I wonder whether when(coordinatorRequestManager.coordinator()).thenReturn(Optional.empty()); might be preferable here. Makes it clear what is being asserted.
Collaborator
Author
Good catch. I'll address this in this patch as well. |
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.
CommitRequestManager#maximumTimeToWait()returned the raw remainingtime of the auto-commit timer, which becomes
0once the intervalelapses. However,
poll()cannot actually send an auto-commit untilthe coordinator is known; it returns
EMPTYwhilecoordinatorRequestManager.coordinator()is empty. When bootstrap DNSresolution is still in progress (
bootstrap.resolve.timeout.ms > 0) andauto.commit.interval.msis shorter than the resolution window, theauto-commit timer can expire before the coordinator is discovered.
remainingMs()then continues to return0indefinitely, since thetimer is not reset until the application thread successfully sends an
auto-commit.
This
0is propagated toConsumerNetworkThread#cachedMaximumTimeToWait, which bounds thepollTimeoutinAsyncKafkaConsumer#pollForFetches()to0, causingthe application and network threads to busy-loop for as long as the
coordinator remains unknown.
Reviewers: Chia-Ping Tsai chia7712@gmail.com, Andrew Schofield
aschofield@confluent.io