Skip to main content

Module index_lock_wait

Module index_lock_wait 

Source
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§

BackoffState
What: Git’s backoff position: step is Git’s n, multiplier the wait base in milliseconds. Why: BackoffState in 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; random is a value in [0, 1).
next_backoff
What: The next backoff: multiplier += 2n + 1, capped at BACKOFF_MAX_MULTIPLIER. Why: Adding 2n + 1 makes the multiplier the square of the step, which is Git’s schedule.