Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data migration: add data migration best practices #10550

Merged
merged 25 commits into from Sep 30, 2022

Conversation

hfxsd
Copy link
Collaborator

@hfxsd hfxsd commented Sep 26, 2022

What is changed, added or deleted? (Required)

Add data migration best practices.

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions.

  • master (the latest development version)
  • v6.3 (TiDB 6.3 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)
  • v5.3 (TiDB 5.3 versions)
  • v5.2 (TiDB 5.2 versions)
  • v5.1 (TiDB 5.1 versions)
  • v5.0 (TiDB 5.0 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@ti-chi-bot
Copy link
Member

ti-chi-bot commented Sep 26, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • qiancai

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@hfxsd hfxsd marked this pull request as draft September 26, 2022 13:45
@ti-chi-bot ti-chi-bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 26, 2022
@hfxsd hfxsd self-assigned this Sep 26, 2022
@ti-chi-bot ti-chi-bot added missing-translation-status This PR does not have translation status info. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 26, 2022
@hfxsd hfxsd added area/best-practices TiDB best practices area/dm translation/from-docs-cn This PR is translated from a PR in pingcap/docs-cn. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. missing-translation-status This PR does not have translation status info. labels Sep 26, 2022
@ti-chi-bot ti-chi-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 27, 2022
@ti-chi-bot ti-chi-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 28, 2022
@hfxsd hfxsd marked this pull request as ready for review September 28, 2022 15:50
@ti-chi-bot ti-chi-bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 28, 2022
@hfxsd hfxsd requested a review from qiancai September 29, 2022 03:04
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved

#### Character sets and collations

Since TiDB v6.0.0, the new framework for collations is used by default. If you want TiDB to support utf8_general_ci, utf8mb4_general_ci, utf8_unicode_ci, utf8mb4_unicode_ci, gbk_chinese_ci and gbk_bin, you need explicitly declare it when creating the cluster by setting the value of `new_collations_enabled_on_first_bootstrap` to `true`. For more information, see [New framework for collations](/character-set-and-collation.md#new-framework-for-collations).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new_collations_enabled_on_first_bootstrap is true by default since v6.0.0, so there is no need to explicitly declare it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revised. PTAL.

dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved
dm/dm-best-practices.md Outdated Show resolved Hide resolved

- When you use DM to perform long-time data replication, sometimes the migration task is blocked for a long time due to various reasons. If you enable the relay log, you can effectively deal with the problem of upstream Binlog being recycled due to the blocking of the migration task.

There are some restrictions using the relay log. DM supports high availability. When a DM-worker fails, it will try to promote an idle DM-worker instance to a working instance. If the upstream Binlog does not contain the necessary migration logs, it may cause interruption. You need to intervene manually to copy the relay log to the new DM-worker node as soon as possible, and modify the corresponding relay meta file. For details, see [Troubleshooting](/dm/dm-error-handling.md#the-relay-unit-throws-error-event-from--in--diff-from-passed-in-event--or-a-migration-task-is-interrupted-with-failing-to-get-or-parse-binlog-errors-like-get-binlog-error-error-1236-hy000-and-binlog-checksum-mismatch-data-may-be-corrupted-returned).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
There are some restrictions using the relay log. DM supports high availability. When a DM-worker fails, it will try to promote an idle DM-worker instance to a working instance. If the upstream Binlog does not contain the necessary migration logs, it may cause interruption. You need to intervene manually to copy the relay log to the new DM-worker node as soon as possible, and modify the corresponding relay meta file. For details, see [Troubleshooting](/dm/dm-error-handling.md#the-relay-unit-throws-error-event-from--in--diff-from-passed-in-event--or-a-migration-task-is-interrupted-with-failing-to-get-or-parse-binlog-errors-like-get-binlog-error-error-1236-hy000-and-binlog-checksum-mismatch-data-may-be-corrupted-returned).
There are some restrictions on using the relay log. DM supports high availability. When a DM-worker fails, it will try to promote an idle DM-worker instance to a working instance. If the upstream binlogs do not contain the necessary migration logs, it may cause interruption. You need to intervene manually to copy the relay log to the new DM-worker node as soon as possible, and modify the corresponding relay meta file. For details, see [Troubleshooting](/dm/dm-error-handling.md#the-relay-unit-throws-error-event-from--in--diff-from-passed-in-event--or-a-migration-task-is-interrupted-with-failing-to-get-or-parse-binlog-errors-like-get-binlog-error-error-1236-hy000-and-binlog-checksum-mismatch-data-may-be-corrupted-returned).


#### Use PT-osc/GH-ost in upstream

In daily MySQL operation and maintenance, usually you use tools such as PT-osc/GH-ost to change the schema online to minimize impact on the business. However, the whole process will be logged to MySQL Binlog. Migrating such data to TiDB downstream will result in a lot of write operations, which is neither efficient nor economical.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In daily MySQL operation and maintenance, usually you use tools such as PT-osc/GH-ost to change the schema online to minimize impact on the business. However, the whole process will be logged to MySQL Binlog. Migrating such data to TiDB downstream will result in a lot of write operations, which is neither efficient nor economical.
In daily MySQL operation and maintenance, usually you use tools such as PT-osc/GH-ost to change the schema online to minimize impact on the business. However, the whole process will be logged to MySQL Binlog. Migrating such data to TiDB downstream will result in a lot of unnecessary write operations, which is neither efficient nor economical.


## Best practices during migration

This section introduces how to troubleshoot problems you encounter during migration.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This section introduces how to troubleshoot problems you encounter during migration.
This section introduces how to troubleshoot problems you might encounter during migration.


### Interrupted migration task due to failed DDL

DM supports skipping or replacing DDL statements that cause the migration task to interrupt. For details, see [Handle Failed DDL Statements](/dm/handle-failed-ddl-statements.md#usage-examples).
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
DM supports skipping or replacing DDL statements that cause the migration task to interrupt. For details, see [Handle Failed DDL Statements](/dm/handle-failed-ddl-statements.md#usage-examples).
DM supports skipping or replacing DDL statements that cause a migration task to interrupt. For details, see [Handle Failed DDL Statements](/dm/handle-failed-ddl-statements.md#usage-examples).

Copy link
Collaborator

@qiancai qiancai left a comment

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 added the status/LGT1 Indicates that a PR has LGTM 1. label Sep 30, 2022
Co-authored-by: Grace Cai <qqzczy@126.com>
@hfxsd
Copy link
Collaborator Author

hfxsd commented Sep 30, 2022

/merge

@ti-chi-bot
Copy link
Member

@hfxsd: /merge in this pull request requires 2 approval(s).

In response to this:

/merge

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.

@hfxsd hfxsd added the require-LGT1 Indicates that the PR requires an LGTM. label Sep 30, 2022
@hfxsd
Copy link
Collaborator Author

hfxsd commented Sep 30, 2022

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: e87f109

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Sep 30, 2022
@ti-chi-bot ti-chi-bot merged commit c051aff into pingcap:master Sep 30, 2022
@ti-chi-bot
Copy link
Member

In response to a cherrypick label: new pull request created: #10619.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/best-practices TiDB best practices area/dm require-LGT1 Indicates that the PR requires an LGTM. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT1 Indicates that a PR has LGTM 1. translation/from-docs-cn This PR is translated from a PR in pingcap/docs-cn.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants