[SPARK-49442][SS] Cache Kafka partition metadata to reduce DescribeTopics RPCs per micro-batch#57351
Open
vinodkc wants to merge 1 commit into
Open
[SPARK-49442][SS] Cache Kafka partition metadata to reduce DescribeTopics RPCs per micro-batch#57351vinodkc wants to merge 1 commit into
vinodkc wants to merge 1 commit into
Conversation
HeartSaVioR
approved these changes
Jul 20, 2026
HeartSaVioR
left a comment
Contributor
There was a problem hiding this comment.
+1 but let's see whether it's possible to give more room for the potential flakiness test issue.
| val topic = newTopic() | ||
| testUtils.createTopic(topic, partitions = 3) | ||
|
|
||
| val ttlMs = 200 // short TTL so the test doesn't need to sleep long |
Contributor
There was a problem hiding this comment.
Generally I'd give more room for slow CI, especially the fact that we run embedded kafka cluster and rely on it, which could also give a fluctuated performance under slow CI.
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.
What changes were proposed in this pull request?
Adds a new source option
partition.metadata.cache.ttl.mstoKafkaOffsetReaderAdmin. When set to a positive value, the driver caches the set of assignedTopicPartitions and reuses it for all offset fetch calls within the TTL window, skipping theDescribeTopicsRPC to the broker. The cache is invalidated on admin reset (i.e., on retry). Default is-1(caching disabled, preserving existing behavior).Why are the changes needed?
Every micro-batch unconditionally called
consumerStrategy.assignedTopicPartitions(admin), which issues aDescribeTopicsRPC to the Kafka broker even though partition assignments are stable in most production deployments. For deployments with large partition counts and short trigger intervals, this generates unnecessary metadata traffic.Does this PR introduce any user-facing change?
Yes. Adds a new source option
partition.metadata.cache.ttl.ms(long, default-1). Valid values are-1(caching disabled) or any positive integer representing milliseconds. Documentation is updated accordingly. Existing behavior is unchanged when the option is not set.How was this patch tested?
Added tests in
KafkaOffsetReaderSuiteKafkaSourceProviderSuite,KafkaOffsetReaderSuiteandKafkaSourceProviderSuite.Was this patch authored or co-authored using generative AI tooling?
Yes, 'Generated-by: Claude (Sonnet 4.6)