Use total stream partition count for realtime partition function divisor#18708
Merged
Jackie-Jiang merged 1 commit intoJun 9, 2026
Merged
Conversation
`RealtimeSegmentDataManager.setPartitionParameters` derived the partition function divisor (`numPartitions`) from `computePartitionGroupMetadata(..., emptyList(), ...).size()`. That call fetches and discards a `StreamPartitionMsgOffset` for every partition just to take the list size, and — more importantly — returns the wrong count in two cases: - Kafka partition-subset feature (`stream.kafka.partition.ids`): the override returns the subset size, not the topic's full partition count. The subset also preserves the original Kafka partition ids as the partition group ids, so a divisor equal to the subset size cannot even represent those ids. The segment partition metadata is computed inconsistently and partition pruning can prune valid segments, returning wrong results. - Kinesis: the override excludes expired shards, so the count reflects active shards rather than the producer's hashing space. The divisor must match the partition count the upstream producer hashed each key over. `fetchPartitionCount` returns exactly that with a single call, so switch to it. Kinesis partitioning remains unsupported (shards split/merge and ids are not a contiguous 0..N range); a TODO records this. Also refresh the stale surrounding comments (no metric is emitted; the mismatch is logged) and align the fetch-failure log message with the timeout.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #18708 +/- ##
============================================
+ Coverage 56.92% 64.49% +7.57%
- Complexity 7 1291 +1284
============================================
Files 2587 3372 +785
Lines 150165 208650 +58485
Branches 24274 32595 +8321
============================================
+ Hits 85485 134575 +49090
- Misses 57460 63282 +5822
- Partials 7220 10793 +3573
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
xiangfu0
approved these changes
Jun 9, 2026
Contributor
|
Opened the corresponding docs update PR: pinot-contrib/pinot-docs#861 |
xiangfu0
added a commit
to pinot-contrib/pinot-docs
that referenced
this pull request
Jun 9, 2026
## Summary - clarify that Kafka subset-partition ingestion still uses the full Kafka topic partition count for realtime segment partition metadata - document that `segmentPartitionConfig.numPartitions` must match the full topic partition count, not the consumed subset size, when partition pruning is enabled ## Source cross-check - `pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java` - `pinot-plugins/pinot-stream-ingestion/pinot-kafka-3.0/src/test/java/org/apache/pinot/plugin/stream/kafka30/KafkaPartitionLevelConsumerTest.java` - `pinot-plugins/pinot-stream-ingestion/pinot-kafka-4.0/src/test/java/org/apache/pinot/plugin/stream/kafka40/KafkaPartitionLevelConsumerTest.java` ## Validation - `git diff --check`
Akanksha-kedia
pushed a commit
to Akanksha-kedia/pinot
that referenced
this pull request
Jun 10, 2026
cypherean
pushed a commit
to cypherean/pinot
that referenced
this pull request
Jun 24, 2026
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.
Summary
RealtimeSegmentDataManager.setPartitionParametersderived the partition function divisor (numPartitions) fromcomputePartitionGroupMetadata(clientId, streamConfig, emptyList(), timeoutMs).size(). That call fetches and discards aStreamPartitionMsgOffsetfor every partition just to take the list size, and — more importantly — returns the wrong count in two cases:stream.kafka.partition.ids): theKafkaStreamMetadataProvideroverride returns the subset size, not the topic's full partition count. The subset path also preserves the original Kafka partition ids as the partition group ids, so a divisor equal to the subset size cannot even represent those ids (e.g. a subset{5, 17, 42}with divisor3). The per-segment partition metadata is then computed inconsistently and partition pruning can prune valid segments, returning wrong results..size()reflects active shards rather than the producer's hashing space.The divisor must match the partition count the upstream producer hashed each key over.
fetchPartitionCountreturns exactly that with a single call, so switch to it. For Kafka it resolves viapartitionsFor(topic), i.e. the full topic partition count, independent of any configured subset.Kinesis partitioning remains unsupported (shards split/merge and ids are not a contiguous
0..Nrange); aTODOrecords this.Also refreshed the stale surrounding comments (no metric is emitted on mismatch; it is now logged at
warn), promoted the fetch-failure log toerror, and aligned the failure log message with the actual timeout.🤖 Generated with Claude Code