Expand description
Starting a child again when the operating system refuses it for lack of processes, within a bounded wait.
What:
Starting a child process again when the operating system refuses it for lack of processes.
Why:
A host that has run out of processes (a process limit, a cgroup limit) refuses a start with EAGAIN,
which Rust reports as ErrorKind::WouldBlock.
A refused start started nothing, so starting again is always safe,
and such a shortage usually ends within moments.
Without this the first refusal ends a commit that the next attempt would have finished.
The wait is bounded, so the wrapper still never stalls: a shortage that outlasts the budget fails with the
same error as before plus how often the start was refused.
In TS you’d write (pseudocode):
for (let delay = 10; ; delay = Math.min(delay * 2, 500)) { try { return start(); } catch (error) { if (!isEagain(error) || waited > 5000) throw error; await wait(delay); } }Constants§
- START_
RETRY_ BUDGET - How long a refused start may wait in total, summed over its pauses.
Traits§
- Retry
Start - Starts of a command that ride out a short shortage of processes.
Functions§
- exec_
retrying - What:
Replace this process with the command, trying again when the replacement is refused for lack of processes.
Returns only the error that ended the attempts.
Why:
execreturns only when it failed, and a failedexecreplaced nothing. - retry_
refused_ start - What:
Run
start, pausing for real between refused tries within the standard budget. Why: The production entry; tests useretry_refused_start_with. - retry_
refused_ start_ with - What:
Run
startuntil it is not refused for lack of processes, pausing between tries. Why: OnlyWouldBlockis retried; every other error is the caller’s, at once. The budget counts the pauses, which dominate the time a refused start takes, so a test can drive it with a recording pause and no real waiting. The final error keeps its kind and says how often the start was refused.