#28: a held write lock is {:error, :busy} and the query store lives on #29
Loading…
Reference in a new issue
No description provided.
Delete branch "mercurius/28-busy-read"
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?
Refs macula-services/mcl-bookclub-phoenix#28
Purpose (fix): a read that meets the PRJ writer's lock answers {:error, :busy}, and the query store lives on.
dfc2af3, red first: bookclub_query_store_test.exs. A second connection holds BEGIN EXCLUSIVE. On main, the warm store's read meets :"$busy" in esqlite3:fetchall1/2 (esqlite3.erl:236) and the store dies: the stack of CI run 6465.00ec229, the fix: read/3 keeps :esqlite3.q/3, which finalizes its statement before it returns, and rescues the CaseClauseError on :"$busy" as {:error, :busy}. Any other CaseClauseError is re-raised.Local: format, compile --warnings-as-errors, credo --strict, all 283 tests, and dialyzer are clean. The Erlang twin is mcl-bookclub PR 16 (#15), same shape.
Refs #30: esqlite ~> 0.10 in both apps' mix.exs (the fix relies on q/3 finalizing, which 0.9.0 does not do; mix.lock already 0.10.1).
The store reads through :esqlite3.q/3 as before, which finalizes its statement before it returns, even on an exception. Its fetch loop has no clause for :"$busy", so a read that met the PRJ writer's lock past esqlite3's own 2 s wait raised a CaseClauseError and the store died (CI run 6465). read/3 answers that one case as {:error, :busy}, which the queries already surface as {:error, {:store_error, :busy}}; any other CaseClauseError is re-raised. Not a hand-rolled prepare/bind/step loop: that leaves each statement for garbage collection, whose destructor runs on a normal scheduler and waits for the connection's mutex, which a waiting step holds for up to 2 s. One scheduler froze (gdb and strace traces), and the short-lock test failed under seed 1. The test also checks the writer can lock again after a busy answer, and reads an id with this file's own suffix ("u"), which no other suite seeds. Refs macula-services/mcl-bookclub-phoenix#28Landed by fast-forward: main is
04efa992f8(from63d4a711). This repository does not allow the manually-merged style, so the PR is closed by hand.Pull request closed