FrankChen021 commented on code in PR #19603:
URL: https://github.com/apache/druid/pull/19603#discussion_r3481290021
##########
server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataManager.java:
##########
@@ -100,12 +100,12 @@ static class PeriodicDatabasePoll implements DatabasePoll
@VisibleForTesting
static class OnDemandDatabasePoll implements DatabasePoll
{
- final long initiationTimeNanos = System.nanoTime();
+ final long initiationTimeMillis = System.currentTimeMillis();
final CompletableFuture<Void> pollCompletionFuture = new
CompletableFuture<>();
- long nanosElapsedFromInitiation()
+ long millisElapsedFromInitiation()
{
- return System.nanoTime() - initiationTimeNanos;
+ return System.currentTimeMillis() - initiationTimeMillis;
Review Comment:
[P2] Use monotonic time for freshness elapsed checks
`millisElapsedFromInitiation()` now computes elapsed time from
`System.currentTimeMillis()`. If the wall clock moves backward after an
on-demand poll starts, this value can become negative or too small, so
`useLatestSnapshotIfWithinDelay()` can keep accepting a stale snapshot and the
periodic poll task can sleep longer than `periodicPollDelay`. Keep a monotonic
`nanoTime()` value for elapsed/freshness calculations and use a separate
wall-clock timestamp only where this code compares against wall-clock poll
start times.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]