Skip to content

util: add support columnar scan details (#69331)#69424

Closed
ti-chi-bot wants to merge 1 commit into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-69331-to-release-nextgen-202603
Closed

util: add support columnar scan details (#69331)#69424
ti-chi-bot wants to merge 1 commit into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-69331-to-release-nextgen-202603

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Jun 24, 2026

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #69331

What problem does this PR solve?

Issue Number: close #69353

Problem Summary:
There is no execution stats summary when the query using columnar instead of tiflash.

What changed and how does it work?

Add columnarScanContext to TiflashStats and collect the stats from tipb::ColumnarScanContext.

TiDB root@localhost:test> explain analyze select * from t;
+----------------------+---------+---------+--------------+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------+----------+------+
| id                   | estRows | actRows | task         | access object | execution info                                                                                                                                                                                                                                                                                                                                                                                                | operator info                             | memory   | disk |
+----------------------+---------+---------+--------------+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------+----------+------+
| TableReader_12       | 8204.00 | 8204    | root         | partition:all | time:63.5ms, loops:10, RU:5.38, cop_task: {num: 2, max: 0s, min: 0s, avg: 0s, p95: 0s, copr_cache_hit_ratio: 0.00}                                                                                                                                                                                                                                                                                            | MppVersion: 2, data:ExchangeSender_11     | 192.7 KB | N/A  |
| └─ExchangeSender_11  | 8204.00 | 8204    | mpp[tiflash] |               | tiflash_task:{time:52.8ms, loops:1, threads:1}                                                                                                                                                                                                                                                                                                                                                                | ExchangeType: PassThrough                 | N/A      | N/A  |
|   └─TableFullScan_10 | 8204.00 | 8204    | mpp[tiflash] | table:t       | tiflash_task:{time:44.8ms, loops:1, threads:1}, columnar_scan:{mvcc_input_rows:8204, mvcc_input_bytes:360976, mvcc_output_rows:8204, regions:1, read_tasks:1, physical_tables:3, columns:3, user_read_bytes:155876, read_block:8ms, serialize_block:0ms, init_reader:12ms, prefetch:0ms, deserialize_block:4ms, rough_check:{total:0, selected:0, skipped:0, unknown:0}, remote_segments:0, total_segments:4} | keep order:false, PartitionTableScan:true | N/A      | N/A  |
+----------------------+---------+---------+--------------+---------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------------------------------------+----------+------+

3 rows in set
Time: 0.077s

Deps

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Summary by CodeRabbit

  • New Features

    • Added support for showing TiFlash columnar scan runtime stats in query execution details.
  • Bug Fixes

    • Improved TiFlash stats handling so aggregated scan metrics are reported more accurately.
    • Updated the bundled TiFlash dependency to a newer version.
  • Tests

    • Added coverage for columnar scan stats formatting and fallback behavior.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603 labels Jun 24, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member Author

@yongman This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot

ti-chi-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

Instructions 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 ti-community-infra/tichi repository.

@ti-chi-bot

ti-chi-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign bb7133 for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Bumps github.com/pingcap/tipb to a new revision exposing ColumnarScanContext in protobuf. Adds TiFlashColumnarScanContext struct and its Clone, String, Merge, mergeExecSummary, and Empty methods to tiflash_stats.go, wires it into basicCopRuntimeStats Clone/Merge/mergeExecSummary, and updates CopRuntimeStats.String to prefer columnar output. Adds a test helper and TestColumnarScanContextStats.

Changes

TiFlash Columnar Scan Stats

Layer / File(s) Summary
tipb dependency bump
go.mod, DEPS.bzl
github.com/pingcap/tipb is pinned to v0.0.0-20260617071407-7c071244534b in both go.mod and DEPS.bzl; DEPS.bzl also contains unresolved merge conflict markers within the updated stanza.
TiFlashColumnarScanContext struct and TiflashStats field
pkg/util/execdetails/tiflash_stats.go
TiflashStats gains a columnarScanContext field; the exported TiFlashColumnarScanContext struct is defined with all region, task, byte, timing, rough-check, and segment counter fields.
TiFlashColumnarScanContext lifecycle methods
pkg/util/execdetails/tiflash_stats.go
Clone, String, Merge, mergeExecSummary, and Empty are implemented for TiFlashColumnarScanContext, accumulating fields from tipb.ColumnarScanContext and formatting a columnar_scan:{...} output string.
basicCopRuntimeStats integration
pkg/util/execdetails/runtime_stats.go
Clone, Merge, and mergeExecSummary in basicCopRuntimeStats are extended to handle columnarScanContext; CopRuntimeStats.String outputs columnarScanContext when non-empty, falling back to scanContext.
Test helper and TestColumnarScanContextStats
pkg/util/execdetails/execdetails_test.go
mockExecutorExecutionSummaryForTiFlashColumnar builds a fully populated columnar proto summary; TestColumnarScanContextStats asserts aggregated columnar_scan:{...} fields appear and tiflash_scan:{...} is absent.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • pingcap/tidb#69331: Directly overlaps — adds columnarScanContext to TiflashStats, clones/merges/prints it in runtime_stats.go, and adds the same columnar stats assertions in execdetails_test.go.

Suggested labels

cherry-pick-approved

Suggested reviewers

  • coocood
  • JaySon-Huang
  • 3pointer
  • bb7133

Poem

🐇 Hop hop, the columns align,
Each scan context now starts to shine!
Merge and clone and string and check—
No legacy tiflash_scan to wreck.
The rabbit cheers: the stats are fine! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and correctly summarizes the main change: adding columnar scan detail support.
Description check ✅ Passed The description includes the issue number, problem summary, implementation summary, checklist, and release note section.
Linked Issues check ✅ Passed The changes add columnarScanContext handling, explain output formatting, and tests that match #69353's requested columnar scan summary.
Out of Scope Changes check ✅ Passed The PR stays focused on columnar scan execution stats plus the needed dependency and test updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: err: exit status 1: stderr: go: errors parsing go.mod:\ngo.mod:109: malformed module path "<<<<<<<": invalid char '<'\ngo.mod:111: usage: require module/path v1.2.3\ngo.mod:113: usage: require module/path v1.2.3\n"


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot

ti-chi-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

@ti-chi-bot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-integration-realcluster-test-next-gen 2cd145c link true /test pull-integration-realcluster-test-next-gen
pull-unit-test-next-gen 2cd145c link true /test pull-unit-test-next-gen
pull-build-next-gen 2cd145c link true /test pull-build-next-gen
pull-mysql-client-test-next-gen 2cd145c link true /test pull-mysql-client-test-next-gen

Full PR test history. Your PR dashboard.

Details

Instructions 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
pkg/util/execdetails/tiflash_stats.go (1)

562-707: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Tighten the exported method docs on TiFlashColumnarScanContext.

String is missing a doc comment, and the Clone/Merge/Empty comments mostly restate the method names instead of the behavioral contract. Please document the actual semantics here (for example, that Merge sums counters but keeps maxima for schema-shape fields) so the exported API is self-explanatory.

Suggested comment cleanup
-// Clone implements the deep copy of * TiFlashColumnarScanContext
+// Clone returns a copy of the aggregated columnar scan statistics.
 func (context *TiFlashColumnarScanContext) Clone() TiFlashColumnarScanContext {

+// String formats the columnar scan statistics for EXPLAIN ANALYZE output.
 func (context *TiFlashColumnarScanContext) String() string {

-// Merge make sum to merge the information in TiFlashColumnarScanContext
+// Merge accumulates per-task counters and keeps the maximum schema-shape fields.
 func (context *TiFlashColumnarScanContext) Merge(other TiFlashColumnarScanContext) {

-// Empty check whether TiFlashColumnarScanContext is empty.
+// Empty reports whether no columnar scan statistics have been recorded.
 func (context *TiFlashColumnarScanContext) Empty() bool {
🤖 Prompt for 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.

In `@pkg/util/execdetails/tiflash_stats.go` around lines 562 - 707, The exported
methods on TiFlashColumnarScanContext need clearer documentation: add a proper
doc comment for String and rewrite the existing Clone, Merge, and Empty comments
in terms of behavior instead of restating names. Use the method symbols Clone,
String, Merge, and Empty to describe the contract, especially that Merge
accumulates counters while preserving maxima for shape fields like
physicalTables and columns, and that Clone returns a deep copy of the context.

Source: Coding guidelines

🤖 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 `@DEPS.bzl`:
- Around line 6585-6599: Resolve the unresolved merge conflict in the tipb
go_repository stanza by removing the conflict markers and keeping a single
consistent set of sha256, strip_prefix, and urls in DEPS.bzl; ensure the
selected version matches the intended final go.mod pin so
`@com_github_pingcap_tipb//go-tipb` remains valid.

In `@go.mod`:
- Around line 109-113: Resolve the merge conflict in go.mod by removing the
conflict markers and leaving a single github.com/pingcap/tipb version; choose
the revision that includes ColumnarScanContext so
pkg/util/execdetails/runtime_stats.go and
pkg/util/execdetails/execdetails_test.go stay compatible. After updating go.mod,
make sure the same tipb revision is reflected consistently in DEPS.bzl.

---

Nitpick comments:
In `@pkg/util/execdetails/tiflash_stats.go`:
- Around line 562-707: The exported methods on TiFlashColumnarScanContext need
clearer documentation: add a proper doc comment for String and rewrite the
existing Clone, Merge, and Empty comments in terms of behavior instead of
restating names. Use the method symbols Clone, String, Merge, and Empty to
describe the contract, especially that Merge accumulates counters while
preserving maxima for shape fields like physicalTables and columns, and that
Clone returns a deep copy of the context.
🪄 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: 0f8998fb-764f-402b-b7ee-180a53c358f9

📥 Commits

Reviewing files that changed from the base of the PR and between 06a52ed and 2cd145c.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (5)
  • DEPS.bzl
  • go.mod
  • pkg/util/execdetails/execdetails_test.go
  • pkg/util/execdetails/runtime_stats.go
  • pkg/util/execdetails/tiflash_stats.go

Comment thread DEPS.bzl
Comment on lines +6585 to +6599
<<<<<<< HEAD
sha256 = "2d6aaef873e175599c39f6fe3cf85cabce88a69c157ff7ec4c22fbcbc97648dd",
strip_prefix = "github.com/pingcap/tipb@v0.0.0-20260210113932-1447c9d7e9fe",
urls = [
"http://bazel-cache.pingcap.net:8080/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20260210113932-1447c9d7e9fe.zip",
"http://ats.apps.svc/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20260210113932-1447c9d7e9fe.zip",
"https://cache.hawkingrei.com/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20260210113932-1447c9d7e9fe.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20260210113932-1447c9d7e9fe.zip",
=======
sha256 = "5a8c6a6e4487592fea5550c2a550826bd0ad7025c7bbec12365ecc7aed81db0d",
strip_prefix = "github.com/pingcap/tipb@v0.0.0-20260617071407-7c071244534b",
urls = [
"https://cache.hawkingrei.com/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20260617071407-7c071244534b.zip",
"https://storage.googleapis.com/pingcapmirror/gomod/github.com/pingcap/tipb/com_github_pingcap_tipb-v0.0.0-20260617071407-7c071244534b.zip",
>>>>>>> 9f419ca60ca (util: add support columnar scan details (#69331))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Fix the unresolved conflict in the Bazel tipb pin.

This go_repository stanza is currently invalid Starlark because of the conflict markers, so Bazel cannot resolve @com_github_pingcap_tipb//go-tipb. Resolve it to one sha256/strip_prefix/urls set that matches the final go.mod version.

🤖 Prompt for 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.

In `@DEPS.bzl` around lines 6585 - 6599, Resolve the unresolved merge conflict in
the tipb go_repository stanza by removing the conflict markers and keeping a
single consistent set of sha256, strip_prefix, and urls in DEPS.bzl; ensure the
selected version matches the intended final go.mod pin so
`@com_github_pingcap_tipb//go-tipb` remains valid.

Comment thread go.mod
Comment on lines +109 to +113
<<<<<<< HEAD
github.com/pingcap/tipb v0.0.0-20260210113932-1447c9d7e9fe
=======
github.com/pingcap/tipb v0.0.0-20260617071407-7c071244534b
>>>>>>> 9f419ca60ca (util: add support columnar scan details (#69331))

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Resolve the tipb merge conflict before merging.

These conflict markers make go.mod unparsable, and this PR also needs the resolved github.com/pingcap/tipb revision to be the one that exposes ColumnarScanContext used by pkg/util/execdetails/runtime_stats.go and pkg/util/execdetails/execdetails_test.go. Please collapse this to a single version and keep it consistent with DEPS.bzl.

🤖 Prompt for 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.

In `@go.mod` around lines 109 - 113, Resolve the merge conflict in go.mod by
removing the conflict markers and leaving a single github.com/pingcap/tipb
version; choose the revision that includes ColumnarScanContext so
pkg/util/execdetails/runtime_stats.go and
pkg/util/execdetails/execdetails_test.go stay compatible. After updating go.mod,
make sure the same tipb revision is reflected consistently in DEPS.bzl.

@yongman

yongman commented Jun 24, 2026

Copy link
Copy Markdown
Member

/close

@ti-chi-bot ti-chi-bot Bot closed this Jun 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 24, 2026

Copy link
Copy Markdown

@yongman: Closed this PR.

Details

In response to this:

/close

Instructions 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants