You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-11-06 08:49:29 +02:00
Wait now uses a Fibonacci backoff rather than exponential.
This commit is contained in:
@@ -633,15 +633,23 @@ sub waitMore
|
||||
# Capture the end time
|
||||
$$oWait{time_end} = gettimeofday();
|
||||
|
||||
# Calculate the new sleep time
|
||||
$$oWait{sleep} = $$oWait{sleep} * 2 < $$oWait{wait_time} - ($$oWait{time_end} - $$oWait{time_begin}) ?
|
||||
$$oWait{sleep} * 2 : ($$oWait{wait_time} - ($$oWait{time_end} - $$oWait{time_begin})) + .001;
|
||||
|
||||
# Exit if wait time has expired
|
||||
if ((gettimeofday() - $$oWait{time_begin}) < $$oWait{wait_time})
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
# Else calculate the new sleep time
|
||||
my $fSleepNext = $$oWait{sleep} + (defined($$oWait{sleep_prev}) ? $$oWait{sleep_prev} : 0);
|
||||
|
||||
if ($fSleepNext > $$oWait{wait_time} - ($$oWait{time_end} - $$oWait{time_begin}))
|
||||
{
|
||||
$fSleepNext = ($$oWait{wait_time} - ($$oWait{time_end} - $$oWait{time_begin})) + .001
|
||||
}
|
||||
|
||||
$$oWait{sleep_prev} = $$oWait{sleep};
|
||||
$$oWait{sleep} = $fSleepNext;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user