flash: handle TiCI estimate count RPC#10826
flash: handle TiCI estimate count RPC#10826ti-chi-bot[bot] merged 14 commits intopingcap:feature/ftsfrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (3)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
Signed-off-by: wshwsh12 <793703860@qq.com>
Signed-off-by: wshwsh12 <793703860@qq.com>
Signed-off-by: wshwsh12 <793703860@qq.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new TiFlash gRPC endpoint to support TiDB optimizer cardinality estimation for TiCI fulltext queries by forwarding an “estimate count” request to the TiCI search library and returning the result.
Changes:
- Add
FlashService::GetEstimateTiCICountgRPC handler and supporting request parsing / timezone handling. - Expose
TiCIReadTaskPool::tipbToTiCIExprfor reuse when building the TiCI estimate query fromtipbexpressions. - Refactor
getKeyRangesinto a reusable helper inTantivyInputStream.hfor building TiCI range inputs.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dbms/src/Storages/Tantivy/TiCIReadTaskPool.h | Exposes expression conversion helper for building TiCI queries outside the task pool. |
| dbms/src/Storages/Tantivy/TantivyInputStream.h | Moves key-range conversion into a shared helper used by both scan and estimate paths. |
| dbms/src/Flash/FlashService.h | Declares the new GetEstimateTiCICount RPC handler. |
| dbms/src/Flash/FlashService.cpp | Implements the new RPC: parses query/ranges/timezone, calls TiCI estimate_count, and returns the estimate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: wshwsh12 <793703860@qq.com>
Signed-off-by: wshwsh12 <793703860@qq.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
lgtm |
Signed-off-by: wshwsh12 <793703860@qq.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: wshwsh12 <793703860@qq.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: wshwsh12 <793703860@qq.com>
Signed-off-by: wshwsh12 <793703860@qq.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| LOG_WARNING(log, "GetEstimateTiCICount failed with unknown exception"); | ||
| response->set_other_error("other exception"); |
There was a problem hiding this comment.
catch (...) currently logs only a generic message and sets other_error to a generic string, which makes unexpected failures hard to diagnose in production. Consider calling tryLogCurrentException(log, ...) (or otherwise logging the current exception detail) and returning an other_error that at least indicates an unknown exception occurred (so the server log can be correlated).
| LOG_WARNING(log, "GetEstimateTiCICount failed with unknown exception"); | |
| response->set_other_error("other exception"); | |
| try | |
| { | |
| throw; | |
| } | |
| catch (const std::exception & e) | |
| { | |
| LOG_WARNING(log, "GetEstimateTiCICount failed with unknown std exception: {}", e.what()); | |
| } | |
| catch (...) | |
| { | |
| LOG_WARNING(log, "GetEstimateTiCICount failed with unknown non-std exception"); | |
| } | |
| response->set_other_error("unknown exception"); |
| namespace DB::TS | ||
| { | ||
|
|
||
| // Convert literal value from timezone specified in cop request to UTC in-place. |
There was a problem hiding this comment.
The comment says the timezone conversion happens "in-place", but convertPackedU64WithTimezone takes from_time by value and returns the converted value instead of mutating an input parameter. Please adjust the comment (or the signature) so it accurately reflects the behavior.
| // Convert literal value from timezone specified in cop request to UTC in-place. | |
| // Convert a literal value from the timezone specified in the cop request to UTC and return the converted value. |
Signed-off-by: wshwsh12 <793703860@qq.com>
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JinheLin, windtalker 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:
|
|
@wshwsh12: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
What problem does this PR solve?
Issue Number: None
Problem Summary:
TiDB needs TiFlash to expose TiCI-side estimate count so the optimizer can use sampled TiCI fulltext cardinality instead of relying only on local planner estimates.
What is changed and how it works?
Check List
Tests
Manual test:
tici-estimate-skew-20260426-2240.EXPLAIN SELECT COUNT(*) FROM estimate_skew WHERE MATCH(content) AGAINST ('heavyhit' IN BOOLEAN MODE);.4321; exact match count was4000; total table row count was9400.GetEstimateTiCICount done, est_count=4321and TiCIEstimateCountResult { estimated_total_count: 4321, ... }.Side effects
Documentation
Release note