Expand description
Waiting for a foreign index.lock under the classification rules and Git’s backoff schedule.
What:
Waiting for a foreign index.lock under the classification rules:
a proven-alive owner
is waited for without limit,
a dead or evidence-free owner is retried on Git’s backoff
schedule until the unproven budget runs out.
Why:
An index writer must not run beside a landing,
and a lock nobody can prove alive must
not block forever.
Nothing here deletes a lock;
the caller decides what the failure means
(src/index-lock/index-lock-wait.ts).
In TS you’d write (pseudocode):
await waitForIndexLock({ realIndexPath, timeoutMs, consequence, attempt });Structs§
- Backoff
State - What:
Git’s backoff position:
stepis Git’sn,multiplierthe wait base in milliseconds. Why:BackoffStatein the incumbent.
Enums§
- Wait
Failure - What: What one attempt found, or why the wait ended without a result. Why: The caller reports the owner and the consequence; the attempt itself is the lock check.
Constants§
- BACKOFF_
MAX_ MULTIPLIER - Git’s
BACKOFF_MAX_MULTIPLIER: the backoff stops growing here. - INITIAL_
BACKOFF - Backoff before the first wait.
- PROVEN_
BY_ DESCRIPTOR_ POLL_ CAP_ MS - Longest single poll while only an open descriptor proves the owner alive; each poll repeats the open-holder scan, so it polls less often.
- PROVEN_
BY_ PID_ FILE_ POLL_ CAP_ MS - Longest single poll while a PID file proves the owner alive, so its release is noticed promptly.
Traits§
- Wait
Effects - What:
The side effects of a wait,
injected so tests can drive a fake clock and fake holders.
Why:
The host implementation reads
/proc, sleeps and writes standard error; tests script each step.
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. - unproven_
owner_ message - What: The diagnostic text of an unproven-owner failure. Why: The person needs the lock path, the owner state, the budget, what was not done, and the evidence.
- wait_
for_ index_ lock - What:
Wait until the lock is gone,
or fail once a dead or unproven owner outlasts
timeout_ms. Why: A live holder gets an unbounded wait with one diagnostic; other holders get the budget, which includes the evidence gathering because a/procscan is not free.