Skip to content

dm: fix data race in cached WhereHandle#12693

Open
OliverS929 wants to merge 1 commit into
pingcap:masterfrom
OliverS929:fix-issue-12688-wherehandle-race
Open

dm: fix data race in cached WhereHandle#12693
OliverS929 wants to merge 1 commit into
pingcap:masterfrom
OliverS929:fix-issue-12688-wherehandle-race

Conversation

@OliverS929

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: close #12688

DM may reuse the same cached WhereHandle across DML workers, while getWhereIdxByData() may reorder UniqueIdxs in place.

What is changed and how it works?

Protect UniqueIdxs reordering and readers with a mutex while preserving the existing behavior.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Questions

Will it cause performance regression or break compatibility?
Do you need to update user documentation, design documentation or monitoring documentation?

Release note

Please refer to [Release Notes Language Style Guide](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/release-notes-style-guide.html) to write a quality release note.

If you don't think this PR needs a release note then fill it with `None`.

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/needs-triage-completed area/dm Issues or PRs related to DM. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 10, 2026
@OliverS929 OliverS929 force-pushed the fix-issue-12688-wherehandle-race branch from 7c20f25 to 9613602 Compare June 10, 2026 03:26
@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jun 10, 2026
@OliverS929 OliverS929 force-pushed the fix-issue-12688-wherehandle-race branch from 9613602 to 8379d94 Compare June 10, 2026 03:33
@ti-chi-bot

ti-chi-bot Bot commented Jun 10, 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 csuzhangxc 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

@ti-chi-bot ti-chi-bot Bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jun 10, 2026
@OliverS929

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@OliverS929

Copy link
Copy Markdown
Contributor Author

/retest

@OliverS929

Copy link
Copy Markdown
Contributor Author

/retest

@OliverS929 OliverS929 force-pushed the fix-issue-12688-wherehandle-race branch from 8379d94 to 5fb01b0 Compare June 11, 2026 09:15
@OliverS929

Copy link
Copy Markdown
Contributor Author

/retest

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

Labels

area/dm Issues or PRs related to DM. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dm: data race when reusing WhereHandle across DML workers

1 participant