Repository navigation
fix(station-host): use 5000 ms SQLite busy_timeout for foreground host writes - #10468
Merged
Merged
Conversation
…t writes In `pion/station-host`, `host_sessions` borrowed `engine.app.gen().resources.db` from `app.pion`, where `attach_db` hardcoded a `250 ms` `busy_timeout`. Unlike `sessions_actors`'s `store_k` (which retries `SQLITE_BUSY` with exponential backoff), `host_sessions`'s foreground handlers (`open_local`, `message`, `set_thread_title`, `SessionEngine::store`, etc.) run directly on this connection without retry. Under concurrent background SQLite writers on startup (`UsageCounter::serve` running `counter_schema`, `ReadIndexBuilder`, `run_usage_maintenance`, `run_remote_runs_backfill`), `POST /admin-api/sessions` returned HTTP 500 `database is locked` in CI (`station-host` `uploads.mjs:76`). Match Node `station/src/store/store.ts` and the rest of `station-host` by attaching the foreground `host_sessions` connection (and the two write paths in `host_main/src/admin_parts.pion`) with `wait_ms = 5000`. Non-blocking actor ticks (`actor_card_tick`) already override `busy_timeout` to `0` via `station_store::try_now_db`. Add a unit test verifying `attach_host_db` sets `PRAGMA busy_timeout = 5000` and a real-binary regression check in `pion/station-host/tests/uploads.mjs` holding `BEGIN IMMEDIATE` for 400 ms while `POST /admin-api/sessions` runs. Co-authored-by: zuozijian <26162189+zuozijian@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
station-hostCI failed inpion/station-host/tests/uploads.mjs:76(500 !== 200,database is locked) onPOST /admin-api/sessions0.46 s after startup (job 145895759915).Root Cause
pion/station-host/host_sessions/src/app.pionhardcodedsql_db::Db::attach(path, 250)(250 msbusy_timeout), andactor.pion/turns.pion(SessionEngine::store) execute foreground writes (open_local,message,set_thread_title,startTurnFor,endTurn, etc.) directly onengine.app.gen().resources.dbwithout aSQLITE_BUSYretry loop (unlike#remote/#jobsactors inremote.pionthat go throughsessions_actors::local_store_retry_k).UsageCounter::serverunningcounter_schema,ReadIndexBuilder,run_usage_maintenance,run_remote_runs_backfill) touchstillfail.db. Under parallel CI runner load (5 concurrenthost_mainprocesses in Phase 3), a background write lock held past 250 ms causedopen_local'sdb.tx(...)to fail withSQLITE_BUSYand return HTTP 500database is locked.host_main/src/admin_parts.pion(save_profile_checkand/parts/hub/newSession) also usedsql_db::Db::attachwith the default250 mstimeout.Fix
pion/station-host/host_sessions/src/app.pion: ExtractHOST_DB_BUSY_TIMEOUT_MS = 5000andattach_host_db(path)to match Nodestation/src/store/store.ts(5000 ms) and the other foreground/helperstillfail.dbconnections acrossstation-host(host_devices,host_upkeep,host_vault,transcript_usage, etc.). Stays belowActorWatch's8 sstop-enter and10 sstall thresholds; non-blocking ticks (actor_card_tick) continue usingstation_store::try_now_db(PRAGMA busy_timeout = 0).pion/station-host/host_main/src/admin_parts.pion: Passwait_ms=5000to the two foregroundstillfail.dbwrite attachments.pion/station-host/host_sessions/src/app_test.pion: Unit test verifyingattach_host_dbsetsPRAGMA busy_timeout = 5000.pion/station-host/tests/uploads.mjs: Real-binary regression test holdingBEGIN IMMEDIATEfor400 ms(> former250 mstimeout) whilePOST /admin-api/sessionsruns, asserting it waits and returns200.Verification
pionc fmt --checkon modified Pion files (app.pion,app_test.pion,admin_parts.pion)node --check pion/station-host/tests/uploads.mjspion-station-mainCI (station-host,station-host-e2e,station-host-macos, includingmember-reads.test.tsandoverview-workspaces.test.tshandover-lock tests)Model: Gemini 4 Neon (
agy) + independent Opus 5.5 review; test frameworks:pionc test, Nodenode:assert/uploads.mjs.