Skip to content

fix(jobs): don't busy-loop ownstatus on a persistent error (audit M12) - #441

Draft
passcod wants to merge 1 commit into
mainfrom
claude/pr-370-fix-m12-ownstatus-loop
Draft

fix(jobs): don't busy-loop ownstatus on a persistent error (audit M12)#441
passcod wants to merge 1 commit into
mainfrom
claude/pr-370-fix-m12-ownstatus-loop

Conversation

@passcod

@passcod passcod commented Aug 1, 2026

Copy link
Copy Markdown
Member

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:

loop {
    if let Err(err) = record_own_status().await {
        error!();
        continue;          // ← straight back to the top
    }
    sleep(Duration::from_secs(60)).await;
}

A persistent, fast-failing error — the database unreachable, a missing Server::own row — then spins as fast as the query can fail: thousands of connection attempts and error! 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 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.

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 a spawn, 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

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants