[SPARK-49442][SS][FOLLOWUP] Use monotonic clock for Kafka partition cache TTL - #57943
Open
cloud-fan wants to merge 1 commit into
Open
[SPARK-49442][SS][FOLLOWUP] Use monotonic clock for Kafka partition cache TTL#57943cloud-fan wants to merge 1 commit into
cloud-fan wants to merge 1 commit into
Conversation
…ache TTL Measure the partition metadata cache TTL with System.nanoTime so wall-clock adjustments cannot incorrectly extend or expire cached metadata. This follows up apache#57351.
Contributor
Author
uros-b
approved these changes
Aug 12, 2026
Member
|
Thank you @cloud-fan! |
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?
Followup to #57351.
This PR measures the Kafka partition metadata cache TTL with
System.nanoTimeinstead ofSystem.currentTimeMillis. It also represents the cached timestamp withOption[Long]rather thanusing zero as a sentinel. Debug logging continues to report cache age in milliseconds.
Why are the changes needed?
TTL measurement should use a monotonic time source. Wall-clock adjustments can otherwise make a
cache entry appear older or younger than it is, causing premature refreshes or extending its
lifetime.
System.nanoTimemeasures elapsed time without that sensitivity.Does this PR introduce any user-facing change?
No. The cache option and its behavior under a stable clock are unchanged.
How was this patch tested?
Existing cache reuse and expiry coverage was run with Java 17:
All 22 tests passed. No new test was added because the change only substitutes the JVM's monotonic
elapsed-time source; reliably simulating host wall-clock changes is not practical in this suite.
Was this patch authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-5)