Repository navigation
fix(start-wrt): keep activity logging best-effort when the database cannot open - #4520
Conversation
…annot open `activity::log` is documented as best-effort, but the shared connection panicked on open. A factory reset is the case that exposes it: `firstboot` erases the database's directory, so when the reset is the daemon's first log entry since starting, the handler panics after the wipe and never reboots. The router keeps running half-wiped, with SSH down for lack of host keys, until someone restarts it. An open failure is now an ordinary error that the next call retries: `log` drops it, as its contract says, and the activity RPCs return it. The reset proceeds to its reboot.
helix-white
left a comment
There was a problem hiding this comment.
Approved on code at b063925bbaf26cea26e94b4172b7c863cc8e2c1f; the merge-tree check against current master is clean. No correctness regressions found.
CI is not green. Changelog fragments & versions fails in the unchanged release-tooling test at scripts/tests/release-notes-test.mjs:1499: it expects the CLI capability check inside the installation step, but master commit 4a33d49eb moved installation to a composite action and put the capability check in the following step. This is unrelated to this diff, but needs resolution before merge. The riscv64 binary, automated tests, and generated-artifacts jobs remain pending. Prettier, formatting/lockfiles, dependency licenses, and conflict-marker checks passed; image build and deployment were skipped.
The fix removes the activity database's panicking lazy initializer. A failed directory creation, SQLite open, or schema initialization now leaves the cached connection unset: logging discards the error, activity RPCs return a filesystem error, and the next call retries. Consequently, logging after firstboot erases the directory cannot prevent the factory-reset handler from scheduling its reboot. Successful connections retain their existing process lifetime and serialization; entry retention, schema, and API payloads remain unchanged, with no migration.
The shared open helper also serves the setup wizard's alternate-path logger, removing duplicated directory/schema initialization. This is independent of the hardware-button reset in #4519.
Implementation diff: +49 / −25 lines in 1 file (excludes lockfiles, tests, docs, release notes, and changelog).
I reviewed the affected callers and recorded evidence without running builds or tests. The author reports 800 + 18 passing tests, including failed-open retry and directory/schema creation, plus a K1 bench reproduction on the original binary and successful reset/reboot on this branch's binary. Recorded checks also cover recovery without daemon restart and activity RPC/login behavior. The flash wizard path and activity clear were not exercised end to end.
One description correction: the fragment is patch-tier, but the pending release is already 1.4.0, not 1.3.1, under the existing manifest and minor fragment.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
|
@Dominion5254 address ci failures. might just need a rebase |
|
Confirmed: both failed jobs hit the same stale assertion in |
helix-white
left a comment
There was a problem hiding this comment.
Approved at 6a49d096ee656956f810f038eb09a019e1a0604a. The fresh merge-tree check against current master is clean; no correctness findings.
Since my previous review, the branch merged master and changed its fragment to release-notes: true. The activity implementation and its tests are byte-for-byte unchanged, as are the factory-reset and setup callers. The merged release-tooling test now checks the dedicated CLI-capability step, addressing the cause of both earlier CI failures. Fresh CI results are still pending; this approval does not establish that they pass.
The change makes activity database initialization fallible rather than panicking after a factory reset wipes its directory. Logging drops initialization errors, allowing reboot scheduling to proceed; activity RPCs return a filesystem error. Failed initialization leaves the connection unset for the next call to retry. Successful connections keep their existing lifetime and mutex serialization. The alternate-path setup logger reuses the same directory/schema initialization helper. Storage format, API payloads, and entry retention remain unchanged; no migration is needed.
Implementation diff: +49 / −25 lines in 1 file (excludes lockfiles, tests, docs, release notes, and changelog).
Verification evidence remains the author's previously recorded 800 + 18 passing tests and K1 bench reproduction/fix, including recovery after an open failure without restarting the daemon. That evidence predates the master merge; the unchanged implementation supports its relevance, but fresh CI is awaited for the combined head. The flash-wizard path and activity clear remain untested end to end. I ran no builds or tests as reviewer.
The description still names 1.3.1; the manifest's pending release is 1.4.0.
Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol
6a49d09 to
3c9e61c
Compare
Summary
activity::logis documented as best-effort, but the shared SQLite connection panicked when it could not be opened. A factory reset is the case that exposes it:firstbooterases/var/lib/startwrt, so when the reset is the daemon's first activity entry since it started, the handler panics after the wipe and never reboots. The router keeps running half-wiped, with SSH down for lack of host keys, until someone restarts it.The connection is now opened on first use behind
db(). An open failure is an ordinaryFilesystemerror that the next call retries:logdrops it, as its contract says, and the activity RPCs return it. The reset proceeds to its reboot.Changelog fragment:
patch/fixed, for the 1.3.1 changelog.Verification
make start-wrt-test: 800 + 18 pass, including the newa_failed_open_is_retriedandopen_db_creates_the_directory_and_schema.changelog.mjs check-versionare clean.startwrt-cli system factory-resetpanicked atactivity.rs:32(unable to open database file), the CLI got a transport error, and 30 s later the router was still up, half-wiped, with its SSH host keys deleted. On this branch's binary the same precondition producedreboot: Restarting systemabout 40 s after the call and a clean boot on defaults. The entry written after the wipe does not survive:firstbootleaves the overlay pending andmount_rootre-wipes it at boot./var/lib/startwrtwith a regular file madeactivity.listreturnFilesystem Error: failed to open activity database; removing the file made the nextactivity.listsucceed without a daemon restart.activity.listwith the directory absent recreates it and returns an empty list;activity.deleteof an unknown id returns Not Found; a UI login is logged and listed by both the UI RPC and the CLI; the bench smoke checks pass after the reset and the config restore.Not exercised: the flash wizard's
log_topath (sameopen_db; flashing is out of bench reach) andactivity.clear, which uses the samedb()helper asdelete.