Skip to content

Phoebe: simplify reconcile index test to the one structural invariant (stop the regress)#21

Closed
hhuuggoo wants to merge 1 commit into
yaml-rater-fixes-6from
yaml-rater-fixes-7
Closed

Phoebe: simplify reconcile index test to the one structural invariant (stop the regress)#21
hhuuggoo wants to merge 1 commit into
yaml-rater-fixes-6from
yaml-rater-fixes-7

Conversation

@hhuuggoo

Copy link
Copy Markdown
Contributor

Cleans up TestIntegration_ReconcileDeleteCanUseWindowStartIndex to prove the one structural invariant it exists for — the reconcile DELETE's window_start-only predicate can be served by rated_usage_window_start_ix (not a seqscan, not the auth-leading composite) — and drops the accreted parts that generated review findings without gating anything.

  • One hard assertion only: under enable_seqscan=off, the EXPLAIN'd reconcile DELETE must reach rated_usage through rated_usage_window_start_ix. Matches the index by NAME across all node forms — Index Scan/Index Only Scan (using …) and Bitmap Index Scan (on …). On the right-sized population PG 16 actually renders a Bitmap Index Scan, which the previous using …-only match would have failed on; that over-narrow match was the flake.
  • Deleted the default-cost soft-signal (t.Logf) block: planner cost-preference is version/GUC-fragile, its failure mode is a slow reconcile (not a wrong bill), and it gated nothing.
  • Right-sized the setup from 10k rows to 240 ANALYZE'd rows across 24 windows — enough for the predicate to be a genuine index-served slice under seqscan-off; the 10k only backed the now-deleted assertion.
  • Comment/intent rewritten to state honestly: index USABILITY, not a planner-cost-preference or performance guarantee.

Test-file-only (internal/rating/store_integration_test.go); no production code, migrations, or other tests touched.

Contracts

No production or contract change — test-quality only (one EXPLAIN integration test made honest and non-flaky).

TestIntegration_ReconcileDeleteCanUseWindowStartIndex existed to prove ONE
structural invariant: the reconcile DELETE's window_start-only predicate CAN be
served by rated_usage_window_start_ix (not a seqscan, not the auth-leading
composite). The test had accreted a vacuous soft signal and an over-narrow
assertion that flaked across plan renderings. This is test-quality only.

- Keep exactly one hard assertion: under enable_seqscan=off, the EXPLAIN'd
  reconcile DELETE must reach rated_usage through rated_usage_window_start_ix.
  Match the index by NAME across all node forms (Index Scan / Index Only Scan
  via "using …", and Bitmap Index Scan via "on …"). On a right-sized population
  PG 16 actually picks a Bitmap Index Scan, which the old "using …"-only match
  would have failed on — that was the flake.
- Delete the default-cost soft-signal (t.Logf) block: planner cost-preference is
  version/GUC-fragile and its failure mode is a slow reconcile, not a wrong bill,
  so it gated nothing and proved nothing.
- Right-size the population from 10k rows (240 windows) to 240 rows (24 windows),
  which only backed the deleted default-cost assertion. The remaining ANALYZE'd
  set is enough for the predicate to be a real index-served slice under
  seqscan-off.
- Rewrite the comment to state honestly what it proves: index USABILITY for the
  reconcile predicate, not a planner-cost-preference or performance guarantee.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hhuuggoo

Copy link
Copy Markdown
Contributor Author

Landed on main via the squashed rating merge (3b22908). Closing the stack.

@hhuuggoo hhuuggoo closed this Jun 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant