fix(jobs): don't busy-loop ownstatus on a persistent error (audit M12) - #441
Draft
passcod wants to merge 1 commit into
Draft
fix(jobs): don't busy-loop ownstatus on a persistent error (audit M12)#441passcod wants to merge 1 commit into
passcod wants to merge 1 commit into
Conversation
The loop slept at the bottom and `continue`d on error, so the error path skipped the sleep entirely. A persistent, fast-failing error — the database unreachable, a missing `Server::own` row — spins as fast as the query can fail: thousands of connection attempts and `error!` lines a minute until it recovers, hammering the database it is already failing to reach. The sleep moves to the top, which is where `pingtask` puts it for exactly this reason. There's nothing left to `continue` past, so the error path just logs and falls through to the next tick. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SGfH1cdFKPnKpM7ytRThft
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.
Fixes M12 (medium) from the audit in #370.
The bug
The loop slept at the bottom and
continued on error, so the error path skipped the sleep entirely:A persistent, fast-failing error — the database unreachable, a missing
Server::ownrow — then spins as fast as the query can fail: thousands of connection attempts anderror!lines a minute, hammering the database it's already failing to reach and burying the logs.The fix
The sleep moves to the top, which is where the sibling
pingtaskputs it for exactly this reason. There's nothing left tocontinuepast, so the error path just logs and falls through to the next tick.One behaviour change worth noting: the first status is now recorded 60s after start rather than immediately. That matches
pingtask, and the job's own cadence is a minute, so nothing downstream distinguishes the two.No test: this is a
loop { sleep }in aspawn, and asserting on it needs time control the audit rates as moderate-to-hard for a one-line ordering fix. The change is a straight comparison with the sibling job.Generated by Claude Code