Skip to main content

Module watchdog

Module watchdog 

Source
Expand description

Runs a command that is expected to keep talking, and diagnoses it if it stops.

A coverage run hung for over an hour: two web integration tests stopped producing output while the job’s heartbeat kept pulsing, so nothing looked wrong until the deadline killed it β€” with no indication of which tests were responsible. Diagnosing it meant catching the pod live and hand-running pg_stat_activity and /proc inspection before it disappeared. The next occurrence should arrive already diagnosed.

Only for commands whose silence is itself a symptom. The musl link is quiet for twelve minutes and is perfectly healthy; wrapping that would be a way to kill good builds.

Re-exportsΒ§

pub use group::Termination;
pub use supervised::run_supervised;

ModulesΒ§

cpu πŸ”’
CPU time spent by a process and everything it spawned, read from /proc.
group πŸ”’
The process group a watched command runs in, and the signals aimed at it.
supervised πŸ”’
A command run in its own process group so a termination signal reaches all of it.

EnumsΒ§

Verdict πŸ”’

ConstantsΒ§

BUSY_TICKS πŸ”’
CPU time the process tree must spend for its silence to count as work.
REPORT_LIMIT_SECS πŸ”’
How long one diagnostic may run; a hung psql must not hold the failure back.
STALL
How long a watched command may produce nothing and do no CPU work before it is declared stuck.

FunctionsΒ§

database_diagnostics πŸ”’
The psql invocations that describe the database the child was given; none without one, since the ambient server is not the child’s.
diagnose πŸ”’
Everything worth knowing about a stuck run, gathered with the process tree frozen, before it is killed, because killing it drops the database connections and the process tree being diagnosed.
follow_cpu πŸ”’
Moves mark to ticks in either direction; true when the tree gained at least BUSY_TICKS since the mark. Following a drop keeps a total that fell from hiding later work.
pump πŸ”’
Forwards a stream line by line, recording when each line arrived.
report πŸ”’
Best effort: a diagnostic that cannot run must not mask the stall itself.
report_within πŸ”’
run_watched
Runs a command, forwarding its output, and fails if it goes quiet.
run_watched_for
As run_watched, with the silence budget supplied.
watch πŸ”’
Polls the child until it exits, is told to stop, or goes quiet; on a stall the diagnostics are gathered here, with the group frozen but alive.