fix(test): wait for Kafka partitions before publishing - #19817
Open
FrankChen021 wants to merge 5 commits into
Open
fix(test): wait for Kafka partitions before publishing#19817FrankChen021 wants to merge 5 commits into
FrankChen021 wants to merge 5 commits into
Conversation
FrankChen021
marked this pull request as ready for review
July 30, 2026 16:21
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the embedded Kafka test resource used by Druid’s ingestion/embedded tests by eliminating races around partition expansion and by surfacing producer delivery failures that were previously silently ignored.
Changes:
- After increasing a topic’s partition count,
KafkaResource#increasePartitionsInTopicnow blocks until each partition can successfully serve a latest-offset lookup via its leader. KafkaResource#produceRecordsWithoutTransactionnow waits onKafkaProducer.send()futures so publish failures are not silently dropped.KafkaResourceTestadds a regression scenario that increases partitions and immediately publishes records, validating end offsets.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/simulate/KafkaResource.java | Adds leader-readiness verification after createPartitions() and waits for non-transactional send results to surface delivery failures. |
| extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/simulate/KafkaResourceTest.java | Adds a regression check for publishing immediately after partition expansion. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This was referenced Jul 30, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/simulate/KafkaResource.java:330
- The retry predicate relies on operator precedence (
||vs&&) to recurse into the cause chain. Adding parentheses makes the intended logic unambiguous and avoids misreads during maintenance.
extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/simulate/KafkaResource.java:318 - The local variable name
partitionOffsetsis misleading here: the map holdsOffsetSpecrequests, not actual offsets. Renaming it to reflect its contents makes the readiness check easier to understand/maintain.
admin.listOffsets(partitionOffsets).all().get();
}
private Map<String, Object> commonClientProperties()
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.
Description
This fixes a race in the embedded Kafka test resource that was exposed by the failed
KafkaIndexFaultToleranceTestrun in #19754. The failure is unrelated to that PR's dependency changes.After creating a topic or increasing its partition count, the Kafka admin operation can complete before the partition leaders are ready to serve requests. The test helper immediately created an idempotent producer and published records, which could receive
NOT_LEADER_OR_FOLLOWERfollowed by repeatedOUT_OF_ORDER_SEQUENCE_NUMBERresponses. Because the helper ignored the futures returned byKafkaProducer.send(), it could return after silently dropping records; the ingestion test then timed out waiting for rows that never reached Kafka.This PR:
There is no end-user behavior change.
Key changed classes
KafkaResourceKafkaResourceTestThis PR has:
Tests
All pass locally. The fault-tolerance test runs both transactional and non-transactional parameterizations.