Bring transaction_cost_limit into master (re-target of #8) - #9
Merged
Conversation
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
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Brings the
transaction_cost_limitfeature (issue #4) intomasterand applies final 1.0.0 release polish.Why this PR exists: #8 (the feature) was opened against the stacked
modernize-pg14-18-cibranch so its review diff would stay clean while #7 was open. But #7 merged that branch tomasterfirst, and #8 then merged into the already-carried branch — so the feature never reachedmaster. This re-applies the reviewed commits directly on currentmaster.Contents:
transaction_cost_limitimplementation — byte-identical to what CI validated green on Add plan_filter.transaction_cost_limit (issue #4) #8; already reviewed there.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 thedocs/superpowers/design-spec process artifact — its rationale is preserved indocs/adr/0004— gitignoring that path.Merging this makes
masterthe complete, tagged-ready 1.0.0 state.