Skip to content

dm: support FK causality for one-to-one routes (#12675) - #12707

Merged
ti-chi-bot[bot] merged 3 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-12675-to-release-8.5
Jun 11, 2026
Merged

ti-chi-bot[bot] merged 3 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-12675-to-release-8.5

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #12675

What problem does this PR solve?

Issue Number: ref #12350

What is changed and how it works?

Support DM FK causality when foreign_key_checks=1 and syncer.worker-count > 1 with static one-to-one route rules.

This PR:

  • builds FK causality relations with source table identity after route validation
  • makes causality key generation follow the task case-sensitive setting, including routed FK causality keys
  • respects the task case-sensitive setting when matching FK metadata and checking route topology
  • rejects route rules that map multiple source tables in the task to the same target table
  • rejects compact and multiple-rows DML boundary options when foreign_key_checks=1
  • caches successful route topology checks and invalidates the cache after schema/config state changes
  • adds unit and integration test coverage for routed multi-worker FK causality

A follow-up PR will explicitly reject hot updates that can change route/filter/case-sensitive/FK causality mode.

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

Support foreign key causality for static one-to-one routing in DM multi-worker sync.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added area/dm Issues or PRs related to DM. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ 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 Jun 10, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member Author

@OliverS929 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 10, 2026

Copy link
Copy Markdown
Contributor

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

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request introduces support for foreign key (FK) causality in one-to-one routing scenarios within DM. It adds task-level route topology validation, case-insensitive table identity matching, and causality key generation adjustments. However, the pull request contains several critical issues that must be addressed: multiple unresolved git conflict markers are present across several configuration, test, and error definition files. Additionally, there are several potential nil pointer dereference panics in sameForeignKeyTableIdentity, causalityKeySourceTableNameForRowChange, and foreignKeyRouteTopologyTableID that require defensive nil checks.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread dm/_utils/terror_gen/errors_release.txt Outdated
Comment thread dm/config/subtask_test.go Outdated
Comment thread dm/errors.toml Outdated
Comment thread dm/pkg/terror/error_list.go Outdated
Comment thread dm/pkg/terror/error_list.go Outdated
Comment thread dm/pkg/terror/errcode_string.go Outdated
Comment thread dm/pkg/terror/errcode_string.go Outdated
Comment thread dm/pkg/schema/tracker.go
Comment thread dm/syncer/dml.go
Comment thread dm/syncer/syncer.go
@codecov

codecov Bot commented Jun 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.28571% with 10 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.5@01a951d). Learn more about missing BASE report.

Additional details and impacted files
Components Coverage Δ
cdc 57.5924% <0.0000%> (?)
dm 49.3679% <0.0000%> (?)
engine 50.7050% <0.0000%> (?)
Flag Coverage Δ
cdc 57.5924% <90.0000%> (?)
unit 53.5566% <94.2857%> (?)

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

@@               Coverage Diff                @@
##             release-8.5     #12707   +/-   ##
================================================
  Coverage               ?   53.5566%           
================================================
  Files                  ?       1026           
  Lines                  ?     138108           
  Branches               ?          0           
================================================
  Hits                   ?      73966           
  Misses                 ?      58612           
  Partials               ?       5530           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@OliverS929

Copy link
Copy Markdown
Contributor

/retest

@OliverS929

Copy link
Copy Markdown
Contributor

/unhold

@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 10, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

@OliverS929: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

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.

@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 Jun 11, 2026

@Benjamin2037 Benjamin2037 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 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Benjamin2037, OliverS929, yudongusa

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 the approved label Jun 11, 2026
@wuhuizuo

Copy link
Copy Markdown
Contributor

/check-cla

@ti-chi-bot
ti-chi-bot Bot merged commit 6da78d9 into pingcap:release-8.5 Jun 11, 2026
27 checks passed
@ti-chi-bot
ti-chi-bot Bot deleted the cherry-pick-12675-to-release-8.5 branch June 11, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved area/dm Issues or PRs related to DM. cherry-pick-approved Cherry pick PR approved by release team. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ 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.

5 participants