Skip to content

Commit

Permalink
Wait for running queries issued during grace period to finish
Browse files Browse the repository at this point in the history
  • Loading branch information
sopel39 committed Feb 20, 2020
1 parent f7a012e commit 083df41
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ public synchronized void requestShutdown()
//wait for a grace period to start the shutdown sequence
shutdownHandler.schedule(() -> {
List<TaskInfo> activeTasks = getActiveTasks();

// wait for grace period for shutting down state to be observed by the coordinator
sleepUninterruptibly(gracePeriod.toMillis(), MILLISECONDS);

while (activeTasks.size() > 0) {
CountDownLatch countDownLatch = new CountDownLatch(activeTasks.size());

Expand All @@ -109,6 +113,9 @@ public synchronized void requestShutdown()
}

activeTasks = getActiveTasks();

// wait for another grace period for all task states to be observed by the coordinator
sleepUninterruptibly(gracePeriod.toMillis(), MILLISECONDS);
}

// wait for another grace period for all task states to be observed by the coordinator
Expand Down

0 comments on commit 083df41

Please sign in to comment.