loggerd: degrade gracefully on log storage failure instead of aborting - #309
loggerd: degrade gracefully on log storage failure instead of aborting#309PeterPhuTran wants to merge 1 commit into
Conversation
loggerd previously assert()ed on every disk operation (segment directory creation, log file open, compressed write, video container header write), so any storage failure - e.g. an NVMe dropping off the PCIe bus and the ext4 log volume remounting read-only - killed loggerd with SIGABRT. The manager does not restart it, so selfdrived raises processNotRunning for the rest of the drive, which blocks engagement (NO_ENTRY) and force- disengages (SOFT_DISABLE). Logging now degrades instead of crashing: - ZstdFileWriter latches a write_error_ flag on open/write failure and becomes a no-op (mirrors the existing VideoWriter::write behavior) - LoggerState::next() returns false on failure; the segment counter still advances so encoderd segment sync is preserved - logger_rotate() treats a failed rotation as one bounded retry per segment (~60s) - loggerd self-heals if storage recovers mid-route - VideoWriter tolerates open/header failures via a new disable() helper and no longer aborts (also fixes an unconditional fclose(NULL) in the destructor); frames keep draining so IPC queues never back up - bootlog skips cleanly when the log root is not writable Data is dropped while degraded (one LOGE per failed rotation); everything else about the drive keeps working. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Thanks for contributing! A maintainer will review your pull request soon. |
|
Validation update — resilience fix verified on hardware (V2: simulated storage failure) Built this PR branch on the affected comma three (arm64) and ran three scenarios against the patched 1. Storage broken at startup (log root unwritable): ran 100+ seconds with no abort — one 2. Healthy-path regression: normal recording, 3 clean segments with real rlog/qlog content, rotations on schedule, zero errors. 3. Mid-recording storage failure + recovery (filesystem driven to write-failure mid-segment — exercises the same short-write path as the field EIO/read-only remount):
Process alive end-to-end. On stock, the first failed write in segment 1 is an The patched binaries are now the daily-driver loggerd on this device, and the APST mitigation applies at every boot — will report cold-boot field results (dmesg fingerprints) as they accumulate. One note for on-device builders: |
Field incident on 2026-07-10 (same device as FrogAi#309): updated logged a 130KB 'git diff output' record for a dirty working tree; logmessaged crashed publishing it to the 256KB logMessage msgq (msgq asserts 3*msg_size <= queue_size, so anything over ~85KB is fatal while logmessaged's own guard only rejects >2MB). Being unflagged, it stayed dead for the rest of the session - permanent processNotRunning alert and total swaglog loss (the crash of the logging daemon is the one crash it can never log). logmessaged is exactly the kind of always_run, non-safety process this flag exists for. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Field update after ~48h and 14 instrumented boots — one confirmation and one honest correction. The resilience fix is now field-proven. Boot instrumentation captured two real NVMe dropout bursts in the wild (overnight cold power-ons, 21 and 30 I/O-error lines at the signature ~49s mark, dozens of ext4 error lines each). Result with this PR's loggerd running: zero crashes, zero Correction on the APST commit: both field bursts occurred with APST already disabled (applied at boot+14s, bursts at ~49s) — so the |
4a851ef to
a9db669
Compare
|
Done — dropped the APST commit and updated the PR title/body accordingly. This PR is now solely the field-validated loggerd resilience fix (single commit). The hardware trigger investigation continues separately; whatever the cause turns out to be, this fix keeps a storage failure from ever blocking engagement. |
Fix engagement-blocking "Process Not Running: loggerd" when log storage fails mid-drive
Symptom
On a comma three with a Samsung 980 NVMe, the first drive after a full power-off
regularly shows "Process Not Running: loggerd" for the entire drive. Because
processNotRunningis NO_ENTRY + SOFT_DISABLE, this blocks engagement andforce-disengages openpilot ~3s after it appears. A warm restart "fixes" it until
the next cold power-on.
Root cause chain (fully instrumented on-device)
the PCIe bus with a burst of I/O errors — same fingerprint every time:
Warm reboots never trigger it (0/4); cold power-ons do, intermittently. Field
instrumentation has since ruled OUT the drive's APST power-state feature as the
mechanism (bursts occur with APST disabled); the exact trigger remains under
investigation. Related: comma three with NVMe: loggerd crash commaai/openpilot#34742, NVMe Drive Permissions Error on Bootup. commaai/openpilot#35842.
/data/mediatakes error hits and can remount read-only for the restof the power session.
assert()on its next disk op → SIGABRT (apportcore captured) → the manager does not restart it →
processNotRunningpersistsall drive.
Fix — loggerd degrades gracefully instead of aborting
Protects against any storage failure, whatever the underlying hardware cause:
ZstdFileWriterlatches awrite_error_flag on open/write failure and becomes ano-op — mirroring the existing graceful pattern in
VideoWriter::write.LoggerState::next()returns false instead of asserting; the segment counterstill advances so encoderd segment sync is preserved.
logger_rotate()treats a failed rotation as one bounded retry per segment (~60s):loggerd self-heals if storage recovers mid-route.
VideoWritertolerates open/header failures via adisable()helper (also fixes alatent unconditional
fclose(NULL)in its destructor).Net effect: storage failure costs that drive's logs — not openpilot engagement.
Validation
with bounded retries (stock SIGABRTs); healthy-path regression → 3 clean segments;
mid-recording failure via ENOSPC → survives with one latched error per writer,
self-heals within one rotation after space returns.
(21 and 30 I/O-error lines at the ~49s signature, dozens of ext4 error lines).
With this patch: zero crashes, zero alerts, complete routes logged through both
sessions (3-segment and 42-segment routes, full-size rlogs). Before this patch,
the identical event produced a SIGABRT core dump and an engagement-blocking alert
for the rest of the drive.
tests/test_logger.cc.Follow-ups (separate PRs)
🤖 Generated with Claude Code