Skip to content

pkg/executor, pkg/kv, pkg/store: propagate SQL digest for MPP task metadata (#66763) - #69465

Merged
ti-chi-bot[bot] merged 1 commit into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-66763-to-release-nextgen-202603
Jun 27, 2026
Merged

pkg/executor, pkg/kv, pkg/store: propagate SQL digest for MPP task metadata (#66763)#69465
ti-chi-bot[bot] merged 1 commit into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-66763-to-release-nextgen-202603

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #66763

What problem does this PR solve?

Issue Number: ref #66762

Problem Summary:
Short MPP queries (below slow log threshold) are hard to correlate between TiDB dispatch logs and TiFlash task logs because SQL digest is not propagated in mpp.TaskMeta.

What changed and how does it work?

  • Add SQLDigest to kv.MPPDispatchRequest.
  • Extract digest from StmtCtx.SQLDigest() in local MPP coordinator, log it in dispatch/retry/error paths, and carry it in dispatch requests.
  • Populate TaskMeta.SqlDigest in TiDB MPP client for dispatch/cancel/establish connection request metadata.
  • Update module wiring to consume the kvproto change (temporary replace to the branch containing TaskMeta.sql_digest) and refresh Bazel dependency metadata via make bazel_prepare.

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.

Validation commands run:

  • go test ./pkg/kv -run TestNonExistent
  • go test ./pkg/store/copr -run TestNonExistent
  • go test ./pkg/executor/internal/mpp -run TestNonExistent
  • make lint
  • make bazel_prepare (with writable local Bazel cache/output paths in this environment)

Before this PR

# tidb.log
[2026/03/07 17:01:43.356 +08:00] [INFO] [local_mpp_coordinator.go:222] ["Dispatch mpp task"] [timestamp=464748308917911554] [ID=1] [QueryTs=1772874103272248530] [LocalQueryId=2] [ServerID=1445] [address=10.2.12.81:3930] [plan="Table(generic_entity)->Sel([eq(test.generic_entity.type_code, CNY) or(ne(test.generic_entity.attr_id_1, ), ne(test.generic_entity.attr_id_2, ))])->Send(-1, )"] [mpp-version=2] [exchange-compression-mode=NONE] [GatherID=1] [resource_group=default]
# tiflash.log
[2026/03/07 17:01:43.369 +08:00] [INFO] [MPPTaskStatistics.cpp:139] ["{\"query_tso\":464748308917911554,\"task_id\":1,\"is_root\":true,\"sender_executor_id\":\"ExchangeSender_18\",\"executors\":[...],...,"status\":\"FINISHED\",\"error_message\":\"\",\"cpu_ru\":0.6666666666666666,\"read_ru\":0.1273956298828125,\"memory_peak\":3059904,..."] [source="mpp_task_tracing MPP<gather_id:1, query_ts:1772874103272248530, local_query_id:2, server_id:1445, start_ts:464748308917911554,task_id:1>"] [thread_id=191]

After this PR, the sql digest is added to the logging

# tidb.log
[2026/03/08 14:41:45.458 +08:00] [INFO] [local_mpp_coordinator.go:244] ["Dispatch mpp task"] [timestamp=464768756710113282] [ID=1] [QueryTs=1772952105388643615] [LocalQueryId=2] [ServerID=1727] [address=10.2.12.81:3930] [plan="Table(generic_entity)->Sel([eq(test.generic_entity.type_code, CNY) or(ne(test.generic_entity.attr_id_1, ), ne(test.generic_entity.attr_id_2, ))])->Send(-1, )"] [mpp-version=3] [exchange-compression-mode=NONE] [GatherID=1] [resource_group=default] [sqlDigest=212e2a5dbe2a960ed1eb83e179cf830acfa105fe40a941c49699002fca309e74]
# tiflash.log
[2026/03/08 14:41:45.619 +08:00] [INFO] [MPPTaskStatistics.cpp:146] ["{\"query_tso\":464768756710113282,\"task_id\":1,\"is_root\":true,\"sender_executor_id\":\"ExchangeSender_19\",\"executors\":[...],...,\"connection_id\":3621781510,\"connection_alias\":\"\",\"sql_digest\":\"212e2a5dbe2a960ed1eb83e179cf830acfa105fe40a941c49699002fca309e74\",...\"status\":\"FINISHED\",\"error_message\":\"\",\"cpu_ru\":1,\"read_ru\":0.1273956298828125,\"memory_peak\":3060307,..."] [source="mpp_task_tracing MPP<gather_id:1, query_ts:1772952105388643615, local_query_id:2, server_id:1727, start_ts:464768756710113282,task_id:1>"] [thread_id=172]

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

Enhance MPP observability by propagating SQL digest in TiDB MPP task metadata and related dispatch logs.

Summary by CodeRabbit

  • New Features

    • Query execution now propagates SQL and plan digests across distributed execution paths for improved tracking and diagnostics.
    • Logs expanded to include these diagnostic identifiers for better troubleshooting and visibility.
  • Chores

    • Updated a vendored dependency to a newer version with refreshed source metadata and checksum.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603 labels Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 280bc4cf-a99f-4c7e-959b-f2f75ef84ebc

📥 Commits

Reviewing files that changed from the base of the PR and between 06a52ed and 4261ad9.

📒 Files selected for processing (3)
  • pkg/executor/internal/mpp/local_mpp_coordinator.go
  • pkg/kv/mpp.go
  • pkg/store/copr/mpp.go
 _________________________________________________________________________________________________________________________________
< For a successful technology, reality must take precedence over public relations, for Nature cannot be fooled. - Richard Feynman >
 ---------------------------------------------------------------------------------------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@JaySon-Huang

Copy link
Copy Markdown
Contributor

/cc @windtalker @gengliqi

@ti-chi-bot
ti-chi-bot Bot requested review from gengliqi and windtalker June 25, 2026 09:59

@windtalker windtalker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 25, 2026
@coderabbitai

coderabbitai Bot commented Jun 25, 2026

Copy link
Copy Markdown

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}

@codecov

codecov Bot commented Jun 25, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-nextgen-202603@06a52ed). Learn more about missing BASE report.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             release-nextgen-202603     #69465   +/-   ##
===========================================================
  Coverage                          ?   76.1642%           
===========================================================
  Files                             ?       1935           
  Lines                             ?     539949           
  Branches                          ?          0           
===========================================================
  Hits                              ?     411248           
  Misses                            ?     128701           
  Partials                          ?          0           
Flag Coverage Δ
unit 76.1642% <96.1538%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 61.5065% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 48.7522% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ti-chi-bot

ti-chi-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gengliqi, windtalker

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

The pull request process is described 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

@ti-chi-bot ti-chi-bot Bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 27, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 27, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-06-25 10:01:33.876980472 +0000 UTC m=+200977.540205975: ☑️ agreed by windtalker.
  • 2026-06-27 11:50:42.916607943 +0000 UTC m=+380326.579833457: ☑️ agreed by gengliqi.

@ti-chi-bot
ti-chi-bot Bot merged commit c5150a3 into pingcap:release-nextgen-202603 Jun 27, 2026
18 checks passed
@ti-chi-bot
ti-chi-bot Bot deleted the cherry-pick-66763-to-release-nextgen-202603 branch June 27, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants