test(ploeg): make the claimable-index plan test independent of statistics #182
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "ryangr0/ploeg-claimable-index-deterministic"
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?
TestClaim_StillUsesClaimableIndex asked the planner for its preferred plan
on a work_items table holding one seeded row. Whether Postgres preferred
work_items_claimable or a sequential scan depended on the table's
statistics, which autoanalyze refreshes on its own schedule after the other
store tests insert and delete rows. Under parallel load the refresh landed
before the EXPLAIN often enough to flake: with accurate statistics for a
one-row table a sequential scan is genuinely cheaper.
The test now runs the EXPLAIN in a transaction with SET LOCAL
enable_seqscan = off. That removes the statistics dependency and asks the
question the test exists for: can the claim use the partial index at all?
If the query stops implying the index predicate (state = 'queued'), the
planner falls back to another index and the test fails.
The test also EXPLAINed a hand-copied query that had already drifted from
the real one (it lacked NOT operator_owned). The candidate subselect is now
the nextClaimableQuery constant, used by ClaimWithin and EXPLAINed by the
test, so a change to the claim query is what the test checks.
The test also EXPLAINed a hand-copied query that had drifted from the real claim (missing NOT operator_owned); it now EXPLAINs the same constant ClaimWithin uses, under SET LOCAL enable_seqscan = off. Proven to fail when the predicate stops matching; 50/50 passes under a parallel full suite.
Verified with
mise run verifyon the pinned toolchain (all gates passed).Ticket: https://vikunja.webgrip.dev/tasks/1824
🤖 Generated with Claude Code