Skip to content

client: use batch-level runtime trace regions (#10965) - #11062

Open
ti-chi-bot wants to merge 1 commit into
tikv:release-8.5from
ti-chi-bot:cherry-pick-10965-to-release-8.5
Open

client: use batch-level runtime trace regions (#10965)#11062
ti-chi-bot wants to merge 1 commit into
tikv:release-8.5from
ti-chi-bot:cherry-pick-10965-to-release-8.5

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #10965

What problem does this PR solve?

Issue Number: Close #10964

Batched PD client requests currently start one Go runtime trace region per request on the same dispatcher goroutine. Runtime trace regions are goroutine-local and must be nested in LIFO order, so representing batched requests as overlapping per-request regions can make go tool trace fail with errors like:

misuse of region in goroutine 400: region end {898020 pdclient.tsoReqSend} when the inner-most active region start event is {898021 pdclient.tsoReqSend}

This can make Go trace timeline and derived pprof outputs unusable during production diagnosis.

What is changed and how does it work?

Use one batch-level runtime trace region for each batched send path, while preserving per-request opentracing spans:

  • Replace per-request pdclient.tsoReqSend runtime regions with one pdclient.tsoReqSendBatch region in the TSO dispatcher.
  • Replace per-request pdclient.regionReqSend runtime regions with one pdclient.regionReqSendBatch region in the region router client.
  • Keep the per-request opentracing spans unchanged, so request-level tracing remains available through opentracing.
client: use batch-level runtime trace regions

Runtime trace regions are goroutine-local execution intervals and must be
nested in LIFO order. The PD client batch send paths started one runtime trace
region per request on the same dispatcher goroutine, which can make batched
requests appear as overlapping/nonnested regions and break Go trace parsing.

Use a single batch-level runtime trace region for each batched send path and
keep per-request detail in opentracing spans.

Check List

Tests

  • Unit test

Code changes

  • None

Side effects

  • None

Related changes

Release note

None.

Summary by CodeRabbit

  • Bug Fixes
    • Improved tracing consistency for batched request processing across router and TSO dispatch flows.
    • Reduced tracing overhead by using a single batch-level trace for grouped requests rather than creating multiple per-request traces.

close tikv#10964

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Jul 29, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

[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 husharp 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 Jul 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6caee245-f5b4-405d-b201-d60c76782c7f

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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 added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-approved Cherry pick PR approved by release team. contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants