Skip to content

Commit

Permalink
Reduce pod status polling frequency (airbytehq#18144)
Browse files Browse the repository at this point in the history
  • Loading branch information
gosusnp authored and jhammarstedt committed Oct 31, 2022
1 parent fd975fa commit c979d72
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ public boolean waitFor(final long timeout, final TimeUnit unit) throws Interrupt

final long deadline = System.nanoTime() + remainingNanos;
do {
Thread.sleep(Math.min(TimeUnit.NANOSECONDS.toMillis(remainingNanos) + 1, 100));
// The remainingNanos bit is about calculating how much time left for the actual timeout.
// Most of the time we should be sleeping for 500ms except when we get to the actual timeout.
// We are waiting polling every 500ms for status. The trade-off here is between how often
// we poll our status storage (GCS) and how reactive we are to detect that a process is done.
Thread.sleep(Math.min(TimeUnit.NANOSECONDS.toMillis(remainingNanos) + 1, 500));
if (hasExited())
return true;
remainingNanos = deadline - System.nanoTime();
Expand Down

0 comments on commit c979d72

Please sign in to comment.