Repository navigation
fix(transcodenode): count a start in the health report before it runs - #5446
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A transcode node admits a new start under its job cap well before it counts the job in active_jobs: a RequireReady start waits for FFmpeg's first segment first. The API server stops counting its reservation once a health check is newer than it, so a check in that gap showed the node a job lighter than it was, and a burst of starts could all pick it. The health report now adds the admitted slots, by kind as well, read under the admission lock countJob holds while it moves a slot from admitted to counted, so a job is counted exactly once. The report's shape is unchanged, so API servers of any version read it. Fixes #5445 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 12 minutes. View limit details
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Health read the job counts before the drain status, so a start admitted while the node finished draining could show a drained node with a job. Read the status first and report no jobs once it is drained: what a drained node admits is a start it is about to refuse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Zeroing every count on a drained node could hide a session replacement the node had already counted. Leave out only the admitted slots, the starts a drained node is about to refuse, and say in the admin docs that the total and per-kind sums can differ while a job starts too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silo Kody — review completeReview finished. Check the inline comments for findings and verify each suggestion against the code and tests. Reviewing changes in Silo
Review settingsReview OptionsThe following review options are enabled or disabled:
|
Problem
Closes #5445
Related issue: N/A
Validation tasks: changes #1177 C2
Other clients: N/A (no client-visible change)
During a burst of playback starts, the API server could send several of them to the same transcode node, or to a node that then refused them at its job cap. The server counts a start it placed against the node only until that node's next health check. The node, though, left a new start out of the
active_jobsandactive_jobs_by_kindit reports until FFmpeg was ready, for example a 4K start still encoding its first segment. A health check in that window cleared the server's reservation, and the report didn't include the job yet. For that moment the node looked one job lighter than it was.With this change the node reports a start from the moment it accepts it, so the job counts against the node throughout.
Approach
The node already counts accepted-but-not-yet-running work against its own job cap. Its health report now adds that same work to
active_jobs, and toactive_jobs_by_kindunder the kind it will run as (video transcode, audio transcode, remux, trickplay). The report reads both under the same lock the node holds when a job moves from accepted to running, so each job is counted exactly once. A start that fails or is abandoned before it runs drops out of the report.The fix is on the node side because only the node knows what it has accepted. The API server can't tell from a count which jobs a report includes. The health response keeps its shape. A new node gives API servers of any version the accurate count, and an old node with a new API server behaves as before, so a rolling upgrade needs no ordering. Draining, hardware re-probes and
/statusstill count running jobs only. A drained node leaves admitted work out of its report, since anything it admits after draining is a start it is about to refuse.Validation
/healthwhile it waits. On main it reportsactive_jobs 0. With the fix it reports one video transcode, and none after the caller abandons the start. A second test shows that a running start is counted once, and a third that a drained node leaves admitted work out.transcodenodeandnodepoolpackage tests pass with-race.make lint-changedreports no issues.Evidence: https://evidence.siloserver.org/r/silo-server/issue-5445/
Risks
While a start waits for FFmpeg, the admin node list shows it in the node's active jobs, one higher than before. That matches what the node enforces.
A shorter window remains: a start still in transit when the node answers a health check whose response arrives after the reservation was made. That timing is on main too, and this PR doesn't change it. It is tracked in #5447.
Checklist
Council review
Ran as a follow-up of the #5412 review, with one member per round.
Plan check: Opus (claude-opus-5-5, medium) confirmed the node-side boundary and found no double count or leak. Its suggestion to add per-kind counts before clamping was adopted.
Rounds: 2, last reviewed 472ac66
Fixed: health could report
drainedwith a job admitted after the drain completed. It now reads the status first and, once drained, reports only the jobs it counts (round 2 narrowed an earlier version that reported none, which could hide a counted session replacement). The admin docs now say the total and per-kind sums can differ while a job starts. Answered: a start still in transit when a health response is published is a timing window on main as well, filed as #5447. A falsedrainedwhile a same-session replacement swaps its job is possible on main too; this PR no longer hides it.No visual review: nothing a user sees changes.
AI Disclosure
Note
Count admitted jobs in transcodenode health reports before they run
Server.admitJob, and the newServer.unadmitLockedhelper keeps total and per-kind admitted counts in sync when a slot completes or is releasedServer.reportedJobscombines running jobs with admitted, uncounted slots for the health response, including per-kind totals inactive_jobs_by_kindactive_jobsandactive_jobs_by_kindin the health response now include admitted work that has not started yet (e.g. a start waiting on its first segment), so totals can be briefly higher than before; see admin-api.md and jobcap.goMacroscope summarized f8668ab.