This repository was archived by the owner on Jan 24, 2024. It is now read-only.
Fix flaky testDeleteClosedTopics#427
Merged
jiazhai merged 2 commits intostreamnative:masterfrom Apr 8, 2021
Merged
Conversation
hangc0276
approved these changes
Apr 7, 2021
dockerzhang
approved these changes
Apr 8, 2021
jiazhai
approved these changes
Apr 8, 2021
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Motivation
testDeleteClosedTopicsis very easy to fail in CI environment because there's a race condition. #425 closes a group's offset consumers when the channel becomes inactive. However, before Kafka consumer closes, it sends aCOMMIT_OFFSETrequest to commit offsets, which is the behavior of the defaultenable.auto.commit=trueconfig. Currently, KoP acknowledges the offset's associated message id in the callback ofGroupMetadataManager#storeGroup, seeGroupCoordinator#handleCommitOffsets:So it's asynchronous with
handleCommitOffsetsitself. There's a possibility that after the channel was closed andOffsetAcker's consumer was removed and closed,OffsetAcker#ackOffsetswould be invoked again, andgetConsumerwould be invoked so that a new offset consumer would be created to the topic.Here're some related logs in CI tests as the evidence.
We can see after the Kafka consumer was closed, a new offset consumer was created again.
Modifications
ackOffsetsdoes the acknowledgement asynchronously but may triggers the creation of an offset consumer, so this PR makesOffsetAcker#ackOffsetsbe called beforeGroupMetadataManager#storeGroupand it prevents an offset consumer being created after channel is inactive.Besides, it adds some condition checks to the test. In CI environment, sometimes topics cannot be deleted by 404 (
Partitioned topic does not exist).