Skip to content

cloud/dm: add LOCK TABLES to source privilege prerequisites#22598

Open
alastori wants to merge 6 commits intopingcap:release-8.5from
alastori:fix/dm-lock-tables-docs
Open

cloud/dm: add LOCK TABLES to source privilege prerequisites#22598
alastori wants to merge 6 commits intopingcap:release-8.5from
alastori:fix/dm-lock-tables-docs

Conversation

@alastori
Copy link
Collaborator

@alastori alastori commented Mar 20, 2026

Summary

  • Add LOCK TABLES to the source privilege table and GRANT statement in the Cloud DM migration guide
  • Add troubleshooting entry for the LOCK TABLES ... Access denied error during full migration

Why

Cloud DM sets consistency=auto for the dump phase (both dataflow-service and serverless-service set Consistency: "auto" in OnTaskCreating()). For MySQL sources, auto resolves to flush at runtime (FLUSH TABLES WITH READ LOCK), which only requires RELOAD.

However, if FTWRL fails or times out (e.g., long-running queries on the source), dumpling automatically falls back to consistency=lock, which executes LOCK TABLES SQL and requires the LOCK TABLES privilege. Without it, the dump fails with:

[code=32001:class=dump-unit] RawCause: sql: LOCK TABLES ... Error 1044 (42000): Access denied

The DM pre-checker does not catch this because it only validates privileges for the initial auto/flush path, not the lock fallback (see resolveAutoConsistency() in dumpling/export/dump.go and the fallback added in tidb#36576).

Granting LOCK TABLES is defensive but correct — it ensures the dump succeeds regardless of which consistency path dumpling takes at runtime.

Other TiDB Cloud docs (Dumpling migration, OSS DM precheck) already include LOCK TABLES — this PR aligns the Cloud DM page.

Test plan

  • Verify privilege table renders correctly in preview
  • Verify GRANT statement includes LOCK TABLES
  • Verify troubleshooting entry appears under Migration errors

Cloud DM uses consistency=flush for full data migration, which requires
LOCK TABLES on the source — but the docs omitted it. Every user following
the documented GRANT hits a cryptic access-denied error on full migration.

- Add LOCK TABLES to privilege table and GRANT statement
- Add troubleshooting entry for the access-denied error
@ti-chi-bot
Copy link

ti-chi-bot bot commented Mar 20, 2026

[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 lilin90 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 the missing-translation-status This PR does not have translation status info. label Mar 20, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the TiDB Cloud Data Migration (DM) documentation to prevent common user errors during full data migration. It addresses a critical omission by explicitly documenting the LOCK TABLES privilege required for consistent data exports and provides a dedicated troubleshooting guide for related access denied errors. This ensures a smoother migration experience for users by aligning the documentation with the actual technical requirements of the DM tool.

Highlights

  • Documentation Update: The tidb-cloud/migrate-from-mysql-using-data-migration.md guide was updated to include LOCK TABLES in the list of required source database privileges and the example GRANT statement.
  • Troubleshooting Guide Enhancement: A new troubleshooting entry was added to tidb-cloud/tidb-cloud-dm-precheck-and-troubleshooting.md to address the "LOCK TABLES ... Access denied" error encountered during full data migration.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ti-chi-bot ti-chi-bot bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Mar 20, 2026
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 correctly adds the LOCK TABLES privilege to the source database requirements for Data Migration, both in the main guide and in the troubleshooting document. My review includes a minor suggestion to improve wording and terminology consistency in the new troubleshooting section, aligning it better with the documentation style guide.

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@alastori
Copy link
Collaborator Author

cc @GMHDBJD

@alastori
Copy link
Collaborator Author

cc @yitso

The privilege is needed for the lock fallback path, not flush directly.
DM uses consistency=auto which resolves to flush (FTWRL), but falls
back to lock (LOCK TABLES) if FTWRL fails — that's when the privilege
is required.
@alastori
Copy link
Collaborator Author

cc @GMHDBJD @qiancai — requesting review for the LOCK TABLES privilege addition. This addresses the DM prerequisite gap discovered during Premium GA testing (RDS-specific FTWRL fallback). Lab evidence: https://github.com/alastori/tidb-sandbox/tree/main/labs/dm/lab-06-lock-tables-privilege

LOCK TABLES is only required when migrating from managed MySQL services
(RDS, Aurora) where FTWRL is restricted. Self-managed MySQL instances do
not need this privilege. Updated privilege table, GRANT examples, and
troubleshooting to reflect the managed-MySQL-specific scope.

Lab evidence: https://github.com/alastori/tidb-sandbox/tree/main/labs/dm/lab-06-lock-tables-privilege
alastori added a commit to alastori/tidb-docs that referenced this pull request Mar 20, 2026
When migrating from managed MySQL services (RDS, Aurora) where FTWRL is
restricted, DM's consistency=auto mode falls back to LOCK TABLES. Added
conditional privilege documentation to dm-worker-intro, dm-precheck, and
quick-start-with-dm.

Confirmed with Minghao Guo: FTWRL→LOCK TABLES fallback is by design,
Cloud DM defaults to consistency=auto.

Lab evidence: https://github.com/alastori/tidb-sandbox/tree/main/labs/dm/lab-06-lock-tables-privilege
Related: pingcap#22598 (Cloud DM docs)
Related: https://tidb.atlassian.net/browse/DM-12687 (pre-check improvement)
alastori added a commit to alastori/tidb-docs that referenced this pull request Mar 20, 2026
When migrating from managed MySQL services (RDS, Aurora) where FTWRL is
restricted, DM's consistency=auto mode falls back to LOCK TABLES. Added
conditional privilege documentation to dm-worker-intro, dm-precheck, and
quick-start-with-dm.

Confirmed with Minghao Guo: FTWRL→LOCK TABLES fallback is by design,
Cloud DM defaults to consistency=auto.

Lab evidence: https://github.com/alastori/tidb-sandbox/tree/main/labs/dm/lab-06-lock-tables-privilege
Related: pingcap#22598 (Cloud DM docs)
Related: https://tidb.atlassian.net/browse/DM-12687 (pre-check improvement)
- Add Azure Database for MySQL and Google Cloud SQL to all provider lists
- Fix troubleshooting note: LOCK TABLES error CAN occur on self-managed
  MySQL if FTWRL is unavailable for other reasons (e.g., missing RELOAD)
- Use "not permitted" instead of "restricted" for consistency
alastori added a commit to alastori/tidb-docs that referenced this pull request Mar 20, 2026
When migrating from managed MySQL services (RDS, Aurora) where FTWRL is
restricted, DM's consistency=auto mode falls back to LOCK TABLES. Added
conditional privilege documentation to dm-worker-intro, dm-precheck, and
quick-start-with-dm.

Confirmed with Minghao Guo: FTWRL→LOCK TABLES fallback is by design,
Cloud DM defaults to consistency=auto.

Lab evidence: https://github.com/alastori/tidb-sandbox/tree/main/labs/dm/lab-06-lock-tables-privilege
Related: pingcap#22598 (Cloud DM docs)
Related: https://tidb.atlassian.net/browse/DM-12687 (pre-check improvement)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant