Bug: Reorder and remove-ticked on the same shopping list can deadlock #27
Loading…
Add table
Add a link
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?
A reorder and "Remove ticked items" on the same shopping list can deadlock. PostgreSQL then aborts one of the two, and that request fails with a 500. The code is on
stagesince spec 001. The window is very narrow, and the problem was found by reading the code, not by reproducing it.How it happens
All three steps must fall within the time one reorder takes:
SELECT … FOR UPDATEon the list row), reads the open items, e.g. Milk and Bread, and renumbers them one after the other.docs/adr/2026-10-02-shopping-list-item-order.md), so this goes through.Possible fixes
docs/adr/2026-10-02-shopping-list-item-order.md, which names the writes that take the lock, so it needs a new ADR that supersedes that part.SELECT … ORDER BY id FOR UPDATEfirst).Context
Found by the backend planner for spec 002 (shopping list overview previews). It does not involve the change row that spec 002 adds, so it is not fixed there. The integration test matrix of spec 002 (
removeTicked×reorder) is the place to cover it once it is fixed; until then that pair may fail there with40P01.