Skip to content

coprocessor: add batch task data merge negotiation fields - #1497

Draft
0xPoe wants to merge 1 commit into
pingcap:masterfrom
0xPoe:poe-batch-task-data-merge
Draft

coprocessor: add batch task data merge negotiation fields#1497
0xPoe wants to merge 1 commit into
pingcap:masterfrom
0xPoe:poe-batch-task-data-merge

Conversation

@0xPoe

@0xPoe 0xPoe commented Jul 14, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

TiKV can reduce batched analyze response traffic by merging per-task results into Response.data. However, an empty batch_responses cannot distinguish merged results from unprocessed tasks, which can cause double counting and lose execution details.

What is changed and how it works?

Add explicit negotiation:

  • Request.allow_batch_task_data_merge lets the client opt in.
  • StoreBatchTaskResponse.data_merged_into_response confirms that a task's data was merged while preserving its exec_details_v2.

Without client opt-in or store support, per-task responses remain unchanged.

Consumers: TiKV (draft) and pingcap/tidb#69686.
Ref: pingcap/tidb#67449.

@ti-chi-bot

ti-chi-bot Bot commented Jul 14, 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 cfzjywxk 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

@pingcap-cla-assistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Add an explicit negotiation for merging the results of batched
coprocessor tasks into the main response:

- Request.allow_batch_task_data_merge: the client declares it can
  consume a response whose batched tasks' results are merged into the
  single result carried by the response's data (e.g. the per-region
  sampling results of a batched analyze request).
- StoreBatchTaskResponse.data_merged_into_response: the store
  acknowledges a merged task; the batch response carries no data of its
  own but still acknowledges the task and carries its execution details.

A store that does not support merging keeps responding per task, and a
client that does not set the request field keeps receiving per-task
responses, so either side can upgrade first.

Signed-off-by: 0xPoe <poe.liu@pm.me>
@0xPoe
0xPoe force-pushed the poe-batch-task-data-merge branch from bb066a1 to a15dd9c Compare July 14, 2026 12:13
0xPoe added a commit to 0xPoe/tidb that referenced this pull request Jul 20, 2026
Opt Analyze into kvproto batch-task data merging and consume explicit per-task acknowledgements without emitting empty responses. A task without an acknowledgement remains on the existing retry path, so mixed-version stores cannot cause silent statistics loss.

Temporarily replace kvproto with the revision from pingcap/kvproto#1497 until that protocol change merges.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tidb that referenced this pull request Jul 20, 2026
Opt Analyze into kvproto batch-task data merging and consume explicit per-task acknowledgements without emitting empty responses. A task without an acknowledgement remains on the existing retry path, so mixed-version stores cannot cause silent statistics loss.

Temporarily replace kvproto with the revision from pingcap/kvproto#1497 until that protocol change merges.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tikv that referenced this pull request Jul 20, 2026
Temporarily point kvproto at the revision carrying pingcap/kvproto#1497. The request opt-in and per-task acknowledgement fields let TiKV and its clients upgrade independently.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tikv that referenced this pull request Jul 20, 2026
Temporarily point kvproto at the revision carrying pingcap/kvproto#1497. The request opt-in and per-task acknowledgement fields let TiKV and its clients upgrade independently.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tikv that referenced this pull request Jul 20, 2026
Temporarily point kvproto at the revision carrying pingcap/kvproto#1497. The request opt-in and per-task acknowledgement fields let TiKV and its clients upgrade independently.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tikv that referenced this pull request Jul 20, 2026
Temporarily point kvproto at the revision carrying pingcap/kvproto#1497.
The request opt-in and per-task acknowledgement fields let TiKV and its
clients upgrade independently.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tidb that referenced this pull request Jul 23, 2026
Opt Analyze into kvproto batch-task data merging and consume explicit per-task acknowledgements without emitting empty responses. A task without an acknowledgement remains on the existing retry path, so mixed-version stores cannot cause silent statistics loss.

Temporarily replace kvproto with the revision from pingcap/kvproto#1497 until that protocol change merges.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tidb that referenced this pull request Jul 23, 2026
Opt Analyze into kvproto batch-task data merging and consume explicit per-task acknowledgements without emitting empty responses. A task without an acknowledgement remains on the existing retry path, so mixed-version stores cannot cause silent statistics loss.

Temporarily replace kvproto with the revision from pingcap/kvproto#1497 until that protocol change merges.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tikv that referenced this pull request Jul 23, 2026
Temporarily point kvproto at the revision carrying pingcap/kvproto#1497.
The request opt-in and per-task acknowledgement fields let TiKV and its
clients upgrade independently.

Signed-off-by: 0xPoe <poe.liu@pm.me>
0xPoe added a commit to 0xPoe/tidb that referenced this pull request Jul 23, 2026
Opt Analyze into kvproto batch-task data merging and consume explicit
per-task acknowledgements without emitting empty responses. A task
without an acknowledgement remains on the existing retry path, so
mixed-version stores cannot cause silent statistics loss. The
acknowledgement path keeps each task's execution details as unconsumed
stats through a nil-safe runtime-stats append, extracted and shared
with the existing unconsumed-stats collection.

Temporarily replace kvproto with the revision from pingcap/kvproto#1497
until that protocol change merges.

Signed-off-by: 0xPoe <poe.liu@pm.me>
@0xPoe 0xPoe closed this Jul 31, 2026
@0xPoe 0xPoe reopened this Aug 1, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

[FORMAT CHECKER NOTIFICATION]

Notice: To remove the do-not-merge/needs-linked-issue label, please provide the linked issue number on one line in the PR body, for example: Issue Number: close #123 or Issue Number: ref #456.

📖 For more info, you can check the "Contribute Code" section in the development guide.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant