Skip to content

Commit 49b7535

Browse files
committed
Address review comment
Signed-off-by: Vivek Dhiman <approach2vivek@gmail.com>
1 parent 81c9773 commit 49b7535

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

server/src/main/java/org/apache/druid/metadata/SqlSegmentsMetadataManager.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static class PeriodicDatabasePoll implements DatabasePoll
9090
* leadership changes.
9191
*/
9292
final CompletableFuture<Void> firstPollCompletionFuture = new CompletableFuture<>();
93-
long lastPollStartTimestampInMs = -1;
93+
long lastPollStartTimestampInNanos = -1;
9494
}
9595

9696
/**
@@ -429,7 +429,7 @@ private Runnable createPollTaskForStartOrder(long startOrder, PeriodicDatabasePo
429429
lock.lock();
430430
try {
431431
if (startOrder == currentStartPollingOrder) {
432-
periodicDatabasePoll.lastPollStartTimestampInMs = System.currentTimeMillis();
432+
periodicDatabasePoll.lastPollStartTimestampInNanos = System.nanoTime();
433433
poll();
434434
periodicDatabasePoll.firstPollCompletionFuture.complete(null);
435435
latestDatabasePoll = periodicDatabasePoll;
@@ -556,7 +556,6 @@ boolean useLatestSnapshotIfWithinDelay()
556556
@VisibleForTesting
557557
void forceOrWaitOngoingDatabasePoll()
558558
{
559-
long checkStartTime = System.currentTimeMillis();
560559
long checkStartTimeNanos = System.nanoTime();
561560
ReentrantReadWriteLock.WriteLock lock = startStopPollLock.writeLock();
562561
lock.lock();
@@ -565,13 +564,14 @@ void forceOrWaitOngoingDatabasePoll()
565564
try {
566565
//Verify if there was a periodic poll completed while we were waiting for the lock
567566
if (latestDatabasePoll instanceof PeriodicDatabasePoll
568-
&& ((PeriodicDatabasePoll) latestDatabasePoll).lastPollStartTimestampInMs > checkStartTime) {
567+
&& ((PeriodicDatabasePoll) latestDatabasePoll).lastPollStartTimestampInNanos > checkStartTimeNanos) {
569568
return;
570569
}
571-
// Verify if there was a on-demand poll completed while we were waiting for the lock
570+
// Verify if there was an on-demand poll completed while we were waiting for the lock
572571
if (latestDatabasePoll instanceof OnDemandDatabasePoll) {
573572
OnDemandDatabasePoll latestOnDemandPoll = (OnDemandDatabasePoll) latestDatabasePoll;
574573
if (latestOnDemandPoll.initiationTimeNanos > checkStartTimeNanos) {
574+
Futures.getUnchecked(latestOnDemandPoll.pollCompletionFuture);
575575
return;
576576
}
577577
}

0 commit comments

Comments
 (0)