Repository navigation
Summarise the --workers supervisor's state in its log records - #72
Merged
Merged
Conversation
Each restart was one record, with nothing that said the whole fleet was down. The supervisor now logs one "Every worker is failing to start" WARNING when every slot is failing within the stable window at once, and a "Workers recovered" INFO once a worker runs past the window again. "Supervisor finished" gains restarts and abnormal_restarts next to the exit codes it already lists. Added records and fields only; no logger name, message, existing field or stdout output changes. Refs #65
A worker that reaches --max-tasks sooner than the stable window exits with code 0 and is restarted at once, so it never ran past the window and the supervisor kept reporting every worker as failing while that one was working. A clean exit now clears the state too, and the record says which of the two cleared it in recovered_by. The check runs before the restarts so that the record names the process that exited. Refs #65
tokibito
force-pushed
the
summarise-supervisor-state
branch
from
October 9, 2026 05:14
88d26b3 to
5423f16
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second half of #65. Each restart under
--workerswas one record with its delay, and nothing said the whole fleet was down. This adds a summary of the supervisor's state to its log records.What it does
Every worker is failing to startWARNING withworkersand each slot's lastexit_codes. One worker failing on its own does not trigger it; its exit records already say so.Workers recoveredINFO withworker_index,pid,failing_forin seconds, andrecovered_by(uptimeorclean_exit). The WARNING can be logged again if every worker starts failing again later.Supervisor finishedgainsrestarts, the number of workers started in place of one that exited, andabnormal_restarts, the number of those that followed an exit with a code other than 0 or--empty-exit-code. This is the same rule that makes theWorker process exitedrecord a WARNING.Things to look at
--max-tasksin less than ten seconds exits with 0 and is restarted at once, so it never runs for ten seconds; without this the state would read "every worker failing" while that worker was processing tasks. The check runs before the restarts in each loop iteration, so thatpidnames the process that exited rather than its replacement.SIGTTINis not a recovery until it has run for ten seconds or exited cleanly itself; until then it has only not failed yet._report_exit()now takes its abnormal-exit rule from a shared_abnormal()helper; the existing tests pass unmodified.Compatibility
Added records and fields only. No logger name, message, existing field or stdout output changes. Existing projects need no changes. The CHANGELOG entry is under Unreleased.
Rebased onto main after #71: the supervisor sets the worker index and counts the restarts in the same
_spawn(), and the CHANGELOG has both entries.Tests
tests/test_supervisor.pygainsTestSupervisorState: the WARNING logged once when every worker fails, not logged when only one does, cleared by a worker running past the threshold and by a clean exit (with the exited process's pid), not cleared by a newly added slot, and the restart counts for failing workers, clean exits and a run-once supervisor.Run on Python 3.13 / Django 6.0 (SQLite), Python 3.14 / Django 6.1 with
-W error::DeprecationWarning, and the whole suite against PostgreSQL 16.Refs #65