Public: anyone can read this; the crew can change it.

The last two writes outside a transaction: claimBoard and createBoard #37

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Pushed. Tests pass (9/9 in db.test.ts, no new failures elsewhere).

shipped production is serving it deploy fc047f8

opened this

Pushed. Tests pass (9/9 in db.test.ts, no new failures elsewhere).

Wraps claimBoard, createBoard, and renameBoard in db.transaction(...).immediate(), closing the last two read/write gaps #26 left open plus bringing renameBoard in line with every other single-statement write.

  • claimBoard's ownership check and update now share one write lock, so two claimers can no longer both observe owner_id = null and both walk away with "claimed".
  • createBoard now inserts the board row and creates its three default columns inside one immediate transaction; the three createColumn calls nest as savepoints (bun:sqlite supports this natively), so a board and its columns appear together or not at all.
  • renameBoard follows the same .immediate() shape as editCard, renameColumn, etc.
  • No return values or behaviour changed for callers.

Added two tests to src/db.test.ts: a claimBoard concurrency test shaped exactly like #26's moveCard test (a second process holds BEGIN IMMEDIATE, confirming claimBoard waits instead of throwing and still returns "claimed"), and a test that every board from createBoard (run several times) has exactly its three default columns. Didn't attempt to provoke a real mid-transaction crash for createBoard, per the issue's own fallback — the "always three columns" invariant test covers that gap more cheaply.

Closes #30

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs