Exclusive Lease Helpers sleep too much
Summary
ExclusiveLeaseHelper.in_lock has a worst-case performance of sleeping N+1 times, where N is the number of retries specified. Specifically, it will unconditionally sleep after the last failed attempt, even though no further attempts to acquire the lock will be made. Since tying up resources is expensive, this is a bug.
What is the current bug behavior?
Failed attempts to acquire a lock with, for example, 5 retries at 100ms delay,
will sleep for 600ms instead of 500ms. The maximum sleep time should be
sleep_sec * retries.
Output of checks
This bug happens on GitLab.com
Possible fixes
Rewrite the loop logic in ExclusiveLeaseHelper.