Add jitter to job exponential backoff.

fork-5.53.8
Greyson Parrelli 2021-01-16 03:37:11 -05:00
rodzic 93e9dd6425
commit 8f7fe5c3ee
1 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -453,9 +453,12 @@ class JobController {
}
private long calculateNextRunAttemptTime(long currentTime, int nextAttempt, long maxBackoff) {
int boundedAttempt = Math.min(nextAttempt, 30);
long exponentialBackoff = (long) Math.pow(2, boundedAttempt) * 1000;
long actualBackoff = Math.min(exponentialBackoff, maxBackoff);
int boundedAttempt = Math.min(nextAttempt, 30);
long exponentialBackoff = (long) Math.pow(2, boundedAttempt) * 1000;
long actualBackoff = Math.min(exponentialBackoff, maxBackoff);
double jitter = 0.75 + (Math.random() * 0.5);
actualBackoff = (long) (actualBackoff * jitter);
return currentTime + actualBackoff;
}