This repository has been archived by the owner on Jan 24, 2024. It is now read-only.
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
testDeleteClosedTopics
is 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_OFFSET
request to commit offsets, which is the behavior of the defaultenable.auto.commit=true
config. Currently, KoP acknowledges the offset's associated message id in the callback ofGroupMetadataManager#storeGroup
, seeGroupCoordinator#handleCommitOffsets
:So it's asynchronous with
handleCommitOffsets
itself. There's a possibility that after the channel was closed andOffsetAcker
's consumer was removed and closed,OffsetAcker#ackOffsets
would be invoked again, andgetConsumer
would 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
ackOffsets
does the acknowledgement asynchronously but may triggers the creation of an offset consumer, so this PR makesOffsetAcker#ackOffsets
be called beforeGroupMetadataManager#storeGroup
and 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
).