Skip to content

An engine's stderr sink keeps draining when its file cannot be written or a line is not UTF-8 (card a6481313) - #5532

Merged
joelteply merged 2 commits into
canaryfrom
a6481313/child-log-s-pump-stops-draining-on-a-wri
Oct 27, 2026
Merged

joelteply merged 2 commits into
canaryfrom
a6481313/child-log-s-pump-stops-draining-on-a-wri

Conversation

@joelteply

@joelteply joelteply commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Why

An engine whose stderr stops being drained logs nowhere. That costs the diagnosis of any stall and darkens #5528's silent_ms (plan line 6: every fast-path miss loud).

child_log's own contract says: "If the file cannot be written we keep draining and discard, and say so once". But pump() returned on the first open or write error, and lines() returned on the first line that was not UTF-8. Either one dropped the engine's stderr reader for the rest of its life. Card a6481313, found while building #5528.

What

  • Bytes, not strings: pump reads lines as bytes and decodes them lossily. Only a read error, meaning the child's stderr has closed, ends it.
  • Write failures: a failed open, write or rotation drops the file, says so once (serving.llama.log_sink_degraded), and keeps draining and discarding.
  • Recovery: it tries the file again every REOPEN_AFTER_LINES (1024) discarded lines, so a full disk isn't asked on every line, and says when it recovers (serving.llama.log_sink_recovered).
  • Rotation is unchanged, now in write_line.

Verified (enrico, 2026-10-27, head d6275c4)

  • Ratchets against origin/canary: exit 0, all 68 pass. REOPEN_AFTER_LINES carries its derived-or-floor: reason.
  • New tests (unix; they spawn sh):
    • an_unwritable_sink_keeps_draining_the_child: a child writes 4000 lines with non-UTF-8 bytes (about 200 KB, well past the pipe buffer) into a sink whose directory doesn't exist. It exits successfully within the timeout, and the drain ends with it.
    • output_that_is_not_utf8_is_logged_lossily_and_draining_continues: three such lines are all logged, with replacement characters.
  • Not built locally: continuum-engine. enrico is serving, and IntelMac's builds go to CI, so CI is the compile.

🤖 Generated with Claude Code

https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE

…n or a line is not UTF-8 (card a6481313)

child_log's own contract: "If the file cannot be written we keep draining and
discard, and say so once". But pump() returned on the first write or open
error, and lines() returned on the first line that was not UTF-8; either
dropped the engine's stderr reader, so its log and the stall evidence's
silent_ms (#5528) went dark for the rest of its life.

- pump reads lines as bytes and decodes them lossily; only a read error (the
  child's stderr closing) ends it.
- A failed open, write or rotation drops the file, says so once
  (serving.llama.log_sink_degraded), and keeps draining and discarding; it
  tries the file again every REOPEN_AFTER_LINES discarded lines and says when it
  recovers (serving.llama.log_sink_recovered).

Tests (unix): a child writing 4000 non-UTF-8 lines into an unwritable sink runs
to completion and the drain ends with it; non-UTF-8 output is logged with
replacement characters and the lines after it are logged.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
…e length counts as full (Codex on #5532)

Reopening after a failure (and after a rotation) set written=0, so repeated
failures and reopens could grow one file past MAX_BYTES. open_counted reads the
file's length on every open; an unreadable length is treated as full, so the
next line rotates. Test: the directory is missing at first, a near-full log
appears while the child pauses, the reopen counts it and rotates, and neither
generation passes the cap.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FRQWzgSfo79JtnwZywHKrE
@joelteply

Copy link
Copy Markdown
Contributor Author

PASS on exact e00afd1. The previous reopen-length blocker is addressed: initial, recovered and rotated append handles now count existing bytes; unavailable metadata forces rotation. Reviewed the near-cap recovery fixture plus invalid-UTF8 and unavailable-sink drain cases. The drain continues observing lines during sink failure and bounds reopen attempts. Independently verified all selected CI checks passed or intentionally skipped, including engine tests. No local build beside active serving. This is source/test approval; deployment and live fault evidence remain separate.

@joelteply
joelteply merged commit 1f5c479 into canary Oct 27, 2026
26 checks passed
@joelteply
joelteply deleted the a6481313/child-log-s-pump-stops-draining-on-a-wri branch October 27, 2026 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant