Skip to content

Bring transaction_cost_limit into master (re-target of #8) - #9

Merged
Xof merged 2 commits into
masterfrom
transaction-cost-limit-to-master
Jul 21, 2026
Merged

Bring transaction_cost_limit into master (re-target of #8)#9
Xof merged 2 commits into
masterfrom
transaction-cost-limit-to-master

Conversation

@Xof

@Xof Xof commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Brings the transaction_cost_limit feature (issue #4) into master and applies final 1.0.0 release polish.

Why this PR exists: #8 (the feature) was opened against the stacked modernize-pg14-18-ci branch so its review diff would stay clean while #7 was open. But #7 merged that branch to master first, and #8 then merged into the already-carried branch — so the feature never reached master. This re-applies the reviewed commits directly on current master.

Contents:

  1. Design spec + transaction_cost_limit implementation — byte-identical to what CI validated green on Add plan_filter.transaction_cost_limit (issue #4) #8; already reviewed there.
  2. Release polish (new commit d36988d): reword the README intro to describe both cost criteria (the old text said "the only criterion" is the per-statement cost, contradicting the new feature), and drop the docs/superpowers/ design-spec process artifact — its rationale is preserved in docs/adr/0004 — gitignoring that path.

Merging this makes master the complete, tagged-ready 1.0.0 state.

Xof added 2 commits July 21, 2026 12:57
Caps the cumulative estimated plan cost of the statements executed in one
transaction, so a batch interface cannot smuggle unbounded work through
many individually-cheap statements. Requested for throttling PostgREST
batch endpoints and mapping the error to HTTP 429.

- New PGC_SUSET GUC plan_filter.transaction_cost_limit, default 0 (off),
  same SQLSTATE (54001) as the statement limit
- Accounting happens in a new ExecutorStart hook, not the planner hook,
  so every execution is charged: a PREPARE/EXECUTE loop over a cached
  generic plan cannot evade a plan-time accumulator
- A transaction callback zeroes the accumulator on commit/abort/prepare;
  ROLLBACK TO SAVEPOINT does not refund cost already charged
- Plain EXPLAIN and parallel workers are exempt; filter_select_only
  applies as it does to the statement limit
- Regression tests cover the reset, no-refund, generic-plan, EXPLAIN,
  filter_select_only, and SQLSTATE behaviors
- README, ADR 0004, and ARCHITECTURE.md document the design, and warn
  that plan-cost limits are not a security boundary against a hostile
  role: the cost estimate is computed from USERSET planner GUCs a client
  can lower to evade either limit
@Xof
Xof merged commit b324f1d into master Jul 21, 2026
7 checks passed
@Xof Xof mentioned this pull request Jul 21, 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