A busy sqlite read crashes the QRY store #28
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Purpose (fix): a query that meets a locked sqlite file waits or answers an error, and never crashes QueryBookclub.BookclubQueryStore.
Seen: main push run 6465 (ci.yml on
8c86a55), job 26605, 1 failure in 281 tests. The failing test wasa rebound Host reads nothing(apps/mcl_bookclub_phoenix_web/test/admin_api_test.exs:213, the read at :215). The error wasCaseClauseError: no case clause matching :"$busy"in esqlite3.erl:236 (fetchall1/2), called from apps/query_bookclub/lib/query_bookclub/bookclub_query_store.ex:28. That handle_call passes:esqlite3.q/3straight through, and the connection opened at :20 has no busy timeout. When the projection is writing the same file, a read gets$busyand the store process dies, so callers get an exit and not a 200/404. The same commit passed as PR run 6461, so this is timing on a loaded runner, but the crash is real.The Erlang twin has the same shape: macula-services/mcl-bookclub apps/query_bookclub/src/bookclub_query_store.erl:37 (open) and :44-45 (handle_call). The twin issue is filed beside this one.
Done when: the store's connection waits on a locked file (a busy timeout on open) or the store answers {:error, :busy} without dying, and a test holds the write lock from a second connection and shows the read still answers.
Refs macula-services/mcl-bookclub-phoenix#4
Flake attempt 1 (ruled a flake by Mars): main push run 6465, ci.yml on
8c86a55, job 26605 (gates). It failed on this crash:a rebound Host reads nothing, CaseClauseError :"$busy" from bookclub_query_store.ex:28. Rerunning only job 26605, once.Flake attempt 1 result: rerun of job 26605 (main run 6465,
8c86a55) succeeded; run 6465 is now success. The crash this issue names stays open.Landed: PR 29, main
04efa992f8. Commits: red firstdfc2af3, fix00ec229, Jupiter's review fixes02719e3and04efa99. Done-when met: a read that meets a held write lock answers {:error, :busy} without the store dying (esqlite3 waits 2 s on open). bookclub_query_store_test.exs holds the lock from a second connection, checks that the writer can lock again and that a short lock is waited out, and traces that every statement prepared for a busy read is finalized. That last check pins the cause of the scheduler freeze a hand-rolled read loop caused. Erlang twin: macula-services/mcl-bookclub#15 (2b353a70).