planner: keep partition processor for static pruning#68541
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughMake logical-rule disablement plan-aware: optimizer now passes the current logical plan to rule-disable checks and forces ChangesPlan-aware logical rule disabling
Estimated code review effort🎯 4 (Complex) | ⏱️ ~40 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/planner/core/optimizer.go`:
- Around line 1021-1022: The code currently appends interactionRule to
againRuleList when isLogicalRuleDisabled(interactionRule, logic) is true, which
is inverted — change the condition so the rule is re-queued only when it is NOT
disabled; specifically, in the block that tests planChanged && ok &&
isLogicalRuleDisabled(interactionRule, logic), replace the disabled check with
its negation (or call an isLogicalRuleEnabled equivalent) so that
interactionRule is appended only when the rule is enabled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 857c7314-6e52-4d86-9735-67ba55ece808
📒 Files selected for processing (2)
pkg/executor/partition_table_test.gopkg/planner/core/optimizer.go
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #68541 +/- ##
================================================
- Coverage 76.3873% 75.4408% -0.9466%
================================================
Files 2038 2020 -18
Lines 562779 565943 +3164
================================================
- Hits 429892 426952 -2940
- Misses 131969 138987 +7018
+ Partials 918 4 -914
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/planner/core/optimizer.go`:
- Around line 1041-1050: The override/warning in isLogicalRuleDisabled currently
only checks session dynamic-prune flag so it triggers for non-partitioned plans;
change isLogicalRuleDisabled (and the branch handling rule.PartitionProcessor)
to first scan the provided logical plan `logic` for any partitioned-scan nodes
(e.g., any node representing a partitioned table/partitioned table scan) and
only if such a node is present and UseDynamicPruneMode is false call
appendPartitionProcessorStaticPruneBlacklistWarning and return false; otherwise
treat the rule as disabled (return true). Ensure the detection traverses the
logical plan tree starting at `logic` (or use an existing helper that detects
partitioned scans) so the override and warning are plan-aware.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 9ec17418-8ace-4e0f-8dc7-a1817808b9df
📒 Files selected for processing (2)
pkg/executor/partition_table_test.gopkg/planner/core/optimizer.go
What problem does this PR solve?
Issue Number: close #57861
Problem Summary:
In static partition prune mode,
partition_processoris required to rewrite a logical partitioned table scan into concrete partition scans. If the rule is disabled throughmysql.opt_rule_blacklist,SELECT ... FOR UPDATEcan be planned over the logical table scan and return an empty result even though the row exists in a partition.What changed and how does it work?
This PR treats
PartitionProcessoras a correctness rule when the statement uses static partition pruning. In that mode, the logical optimizer ignores the opt-rule blacklist entry forpartition_processor, emits a warning, and still runs the static partition rewrite. Dynamic partition pruning keeps the existing blacklist behavior.It also adds a regression test for a hash-partitioned table with a virtual generated column,
SELECT ... FOR UPDATE, and bothpredicate_push_downandpartition_processorlisted inmysql.opt_rule_blacklist.Check List
Tests
Test command:
go test --tags=intest ./pkg/executor -run TestSelectLockWithStaticPruneAndPartitionProcessorBlacklist -count=1Side effects
Documentation
Release note
Summary by CodeRabbit
Tests
Bug Fixes