Expand description
Waiting for a foreign index.lock under the classification rules and Git’s backoff schedule.
What:
Git’s own lock-retry schedule: the backoff position, its next step, and the jittered wait it prescribes.
Why:
A caller that retries a lock the way Git retries its own waits on the same
schedule, so it neither hammers the lock nor starves behind it. Waiting for a foreign index.lock is gone: a command
that cannot take Git’s index.lock ends as native Git ends it, and the commit service’s landing retries it a bounded
number of times itself (src/index-lock/index-lock-wait.ts is the incumbent of the schedule).
In TS you’d write (pseudocode):
const wait = jitteredWait(state, Math.random()); state = nextBackoff(state);Structs§
- Backoff
State - What:
Git’s backoff position:
stepis Git’sn,multiplierthe wait base in milliseconds. Why:BackoffStatein the incumbent.
Constants§
- BACKOFF_
MAX_ MULTIPLIER - Git’s
BACKOFF_MAX_MULTIPLIER: the backoff stops growing here. - INITIAL_
BACKOFF - Backoff before the first wait.
Functions§
- jittered_
wait - What:
One jittered wait from Git’s formula
(750 + rand() % 500) * backoff / 1000, rounded down. Why: Jitter spreads retrying processes apart;randomis a value in[0, 1). - next_
backoff - What:
The next backoff:
multiplier += 2n + 1, capped atBACKOFF_MAX_MULTIPLIER. Why: Adding2n + 1makes the multiplier the square of the step, which is Git’s schedule.