Skip to main content

Module start_retry

Module start_retry 

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

RetryStart
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: exec returns only when it failed, and a failed exec replaced nothing.
retry_refused_start
What: Run start, pausing for real between refused tries within the standard budget. Why: The production entry; tests use retry_refused_start_with.
retry_refused_start_with
What: Run start until it is not refused for lack of processes, pausing between tries. Why: Only WouldBlock is 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.