-
Notifications
You must be signed in to change notification settings - Fork 3.8k
fix: Fix invalid time comparison #19603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 10 commits
e58b57c
93f3450
de40832
081d603
3d7f809
57df8d3
128b3e9
99607d8
7029e8a
81c9773
49b7535
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -557,6 +557,7 @@ boolean useLatestSnapshotIfWithinDelay() | |
| void forceOrWaitOngoingDatabasePoll() | ||
| { | ||
| long checkStartTime = System.currentTimeMillis(); | ||
| long checkStartTimeNanos = System.nanoTime(); | ||
| ReentrantReadWriteLock.WriteLock lock = startStopPollLock.writeLock(); | ||
| lock.lock(); | ||
| try { | ||
|
|
@@ -569,7 +570,6 @@ void forceOrWaitOngoingDatabasePoll() | |
| } | ||
| // Verify if there was a on-demand poll completed while we were waiting for the lock | ||
| if (latestDatabasePoll instanceof OnDemandDatabasePoll) { | ||
| long checkStartTimeNanos = TimeUnit.MILLISECONDS.toNanos(checkStartTime); | ||
| OnDemandDatabasePoll latestOnDemandPoll = (OnDemandDatabasePoll) latestDatabasePoll; | ||
| if (latestOnDemandPoll.initiationTimeNanos > checkStartTimeNanos) { | ||
|
vivek807 marked this conversation as resolved.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Contended force calls still miss the poll they waited for This still compares the existing on-demand poll's initiation time with the caller's check start. In the common contended path, thread A creates the OnDemandDatabasePoll and holds the write lock while polling; thread B enters forceOrWaitOngoingDatabasePoll after that initiation, waits for the same write lock until A's poll completes, then sees initiationTimeNanos <= checkStartTimeNanos and starts another database poll. That means the PR still serializes duplicate forced polls for callers that arrived during the actual poll, even though the previous poll completed after their call. Track and compare completion time, or otherwise record that the caller waited behind the in-progress on-demand poll, before returning/forcing a new poll. |
||
| return; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.