Skip to content

[SPARK-55699][SS][FOLLOWUP] Inconsistent reading of LowLatencyClock when used together with ManualClock#54550

Open
eason-yuchen-liu wants to merge 2 commits intoapache:masterfrom
eason-yuchen-liu:fixLowLatencyClockInconsistency2
Open

[SPARK-55699][SS][FOLLOWUP] Inconsistent reading of LowLatencyClock when used together with ManualClock#54550
eason-yuchen-liu wants to merge 2 commits intoapache:masterfrom
eason-yuchen-liu:fixLowLatencyClockInconsistency2

Conversation

@eason-yuchen-liu
Copy link
Contributor

@eason-yuchen-liu eason-yuchen-liu commented Feb 28, 2026

What changes were proposed in this pull request?

In the previous PR, we update the signature of nextWithTimeout in SupportsRealTimeRead. However, there was a bug introduced in LowLatencyMemoryStream where we compared millisecond timestamp and nanosecond timestamp directly without conversion.

This PR fixes this issue, and renamed the parameter to better prevent such issue from happening.

Why are the changes needed?

Context of the previous PR: There was an issue that RTM tests that use manual clock might stuck because manual clock advancement may happens right in between LowLatencyReaderWrap getting the reference time, and nextWithTimeout in each source getting the start time. nextWithTimeout may uses the already advanced time to time its wait. When this happens, since the manual clock may only be advanced once by the test, nextWithTimeout may never return, causing test timeout. This only affects LowLatencyMemoryStream when using together with manual clocks.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Existing unit tests.

Was this patch authored or co-authored using generative AI tooling?

No.

@HeartSaVioR HeartSaVioR changed the title [SPARK-55699][SS][Followup] Inconsistent reading of LowLatencyClock when used together with ManualClock [SPARK-55699][SS][FOLLOWUP] Inconsistent reading of LowLatencyClock when used together with ManualClock Mar 1, 2026
@HeartSaVioR
Copy link
Contributor

@eason-yuchen-liu

Could you please update the PR title and description to describe the new change in this PR instead of just duplicating the old one? Also it doesn't look like any existing test wasn't failing and we don't add any test here.

This looks like just to clarify the time unit for the parameter - that's already actually mentioned in the method doc. I'm OK with further clarification rather than relying on method doc; just want to understand the actual change here.

Copy link
Contributor Author

@eason-yuchen-liu eason-yuchen-liu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have update the PR description to reflect the actual change. Thanks.

Thread.sleep(POLL_TIME)
current = getRecordWithTimestamp
elapsedTimeMs = (clock.nanoTime() - startReadTime) / 1000 / 1000
elapsedTimeMs = clock.getTimeMillis() - startTimeMs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HeartSaVioR This is the main change. Basically, in the last PR, we were substract a millisecond off a nano second which is wrong.

I am not sure why no unit test is failing. Maybe this unveils that we have a limited test coverage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants