fix(kernel): wait out shared-registry locks on lease renewal
Summary
Review flows on a loaded Linux host failed lease renewal on the one relayflowd.sqlite3 shared by adversarial-review, context-review, and ci:
journal_write_failed: persist renewed lease deadline: SQLite journal failed: database is locked
Steps then ended as run_terminal … cannot accept mutations. Seen with @relayflows/runtime-linux-x64 2.0.55 at load 20–60.
The registry was already WAL with a 5s busy_timeout, but every short-lived open re-ran PRAGMA journal_mode=WAL (an exclusive lock the busy handler does not cover, retried for about 100ms) and re-executed schema DDL. The run journal set WAL and left busy_timeout at 0.
Every open now waits 15 seconds, switches to WAL only when the file is not already WAL, and skips registry DDL once the schema is current. A write that still cannot commit is returned. It is not swallowed. There is no fleet concurrency cap.
Follow-up 7a569cfc keeps lease_ttl_ms measured from the instant the daemon set the deadline, before the durable write. The worker adds that duration to the time it sent the heartbeat. Measuring after the write counted the wait twice: a 14s lock left the worker about 2s on a lease the daemon had just extended. The worker deadline is unchanged when the write is fast.
Validation
cargo test -p relayflowd-journal --offline -- --test-threads=8 from kernel/: 35 passed, including:
renew_deadline_commits_while_another_connection_holds_a_readrenew_deadline_waits_out_a_short_write_instead_of_failing_lockedrenew_deadline_does_not_swallow_a_write_that_cannot_commitfailed_commit_is_returned_not_swallowed
With the timeout forced to zero, the wait-out test fails with SQLite journal failed: database is locked.
cargo test -p relayflowd --offline --lib -- heartbeat_ttl_keeps_the_full_lease_across_a_slow_durable_write heartbeat_carries_the_remaining_lease_as_a_duration --test-threads=1: both passed. The new test holds BEGIN IMMEDIATE for 2 seconds across the heartbeat and requires lease_ttl_ms >= 29_000.
Agent session: 01a19b64-f33d-7f63-bb7f-eb61212c7809