Files
Erik JohnstonandClaude Opus 5.5 7eac9c44b6 Decide a state group's children first when marking unreferenced ones
The background update that marks unreferenced state groups for deletion
reads a batch of groups joined to their next groups, then decides each
row in turn: a group is a candidate if every next group is. That needs a
group's next groups decided before it, but the query had no outer ORDER
BY, so the order was whatever the join produced. When a group came
first, its next group looked undecided, the group was kept, and once the
next group was deleted it was left behind for good.

`test_clear_unreferenced_state_groups` caught this about one run in ten
on Postgres, and more often as other changes moved the timing. A next
group is always created after its prev group, so has a higher ID:
ordering by ID descending decides it first. The test now passes every
time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PVLsNh6akt4ifEizY4D1ta
2026-10-18 21:34:04 +00:00
..
2026-10-12 18:20:43 +00:00
2026-10-12 18:20:43 +00:00
2026-10-12 18:21:30 +00:00
2026-10-12 18:31:01 +00:00
2026-10-12 18:31:01 +00:00
2026-10-14 15:11:51 +00:00