planner: refactor analyzeTiCIIndex for clearer structure | tidb-test=13ccf8de48e8db2290ff884598444d0508606bbf tiflash=feature-fts#66583
Conversation
|
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 (1)
📝 WalkthroughWalkthroughanalyzeTiCIIndex in Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## feature/fts #66583 +/- ##
===================================================
- Coverage 76.8610% 75.0204% -1.8406%
===================================================
Files 1960 1936 -24
Lines 555677 556268 +591
===================================================
- Hits 427099 417315 -9784
- Misses 127116 138947 +11831
+ Partials 1462 6 -1456
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
pkg/planner/core/operator/logicalop/logical_datasource.go (1)
721-752:⚠️ Potential issue | 🟠 MajorDon’t select a hinted TiCI path when no predicate matched.
Line 746 can still choose a forced index when
tmpMatchedExprSetis empty. That path then reaches the TiCI build/cleanup flow with no matched conditions, after which fallback paths may already be pruned while the TiCI path still qualifies as “unused” becauseAccessCondsstays empty. AUSE_INDEXhint on a TiCI index that matches nothing can therefore strand theDataSourcewithout a usable fallback.🔧 Minimal guard
if !ds.collectMatchedExprSetForTiCIIndex(condHasFTSFunc, ftsCols, invertedIndexedCols, &tmpMatchedExprSet) { continue } + if tmpMatchedExprSet.IsEmpty() { + continue + } // We get here means this index can cover all FTS functions. hasUnmatchedFTSOverAllIdx = false🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@pkg/planner/core/operator/logicalop/logical_datasource.go` around lines 721 - 752, In chooseTiCIIndex, avoid selecting a forced (hinted) index when it matches no predicates: change the selection condition around matchedExprSetForChosenIndex so a path with path.Forced is only chosen if tmpMatchedExprSet.Len() > 0; i.e. require non-empty tmpMatchedExprSet when considering the (path.Forced && !matchedIndexIsHinted) branch while leaving the tmpMatchedExprSet.Len() > matchedExprSetForChosenIndex.Len() branch unchanged; update the logic in chooseTiCIIndex so forced hints cannot be picked when tmpMatchedExprSet is empty to prevent stranded TiCI-only paths.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@pkg/planner/core/operator/logicalop/logical_datasource.go`:
- Around line 721-752: In chooseTiCIIndex, avoid selecting a forced (hinted)
index when it matches no predicates: change the selection condition around
matchedExprSetForChosenIndex so a path with path.Forced is only chosen if
tmpMatchedExprSet.Len() > 0; i.e. require non-empty tmpMatchedExprSet when
considering the (path.Forced && !matchedIndexIsHinted) branch while leaving the
tmpMatchedExprSet.Len() > matchedExprSetForChosenIndex.Len() branch unchanged;
update the logic in chooseTiCIIndex so forced hints cannot be picked when
tmpMatchedExprSet is empty to prevent stranded TiCI-only paths.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 26cec43f-00b6-49ff-96c8-0824d65dbae3
📒 Files selected for processing (2)
pkg/planner/core/casetest/tici/tici_test.gopkg/planner/core/operator/logicalop/logical_datasource.go
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: time-and-fate, wshwsh12 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
|
/retest |
|
/retest |
1 similar comment
|
/retest |
What problem does this PR solve?
Issue Number: ref #66389
Problem Summary:
analyzeTiCIIndexinDataSourcehas dense, mixed responsibilities (dirty-write checks, TiCI path selection, and expression rewrite), making the control flow hard to follow and maintain.What changed and how does it work?
Refactor
analyzeTiCIIndexby moving logic into focused helpers while keeping behavior unchanged:Check List
Tests
Test command:
make failpoint-enable && (pushd pkg/planner/core/casetest/tici >/dev/null && go test -run 'TestTiCIWithDirtyWrites|TestTiCIMatchAgainstValidation' --tags=intest && popd >/dev/null; rc=$?; make failpoint-disable; exit $rc)Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit
Refactor
Bug Fixes
Tests