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

Conflict data resolution enhancement during data import GA #17276

Merged
merged 21 commits into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
fb8e673
Update tidb-lightning-configuration.md
lyzx2001 Apr 19, 2024
cf618d5
update tidb-lightning/tidb-lightning-physical-import-mode-usage.md
lyzx2001 Apr 19, 2024
6208515
Update tidb-lightning/tidb-lightning-physical-import-mode-usage.md
lyzx2001 Apr 19, 2024
5e70986
update according to comments
lyzx2001 Apr 24, 2024
d765f52
update according to comments
lyzx2001 Apr 25, 2024
bc1073a
update according to comments
lyzx2001 Apr 25, 2024
ee4f5d5
Update tidb-lightning/tidb-lightning-configuration.md
lyzx2001 Apr 25, 2024
f746647
Update tidb-lightning/tidb-lightning-logical-import-mode-usage.md
lyzx2001 Apr 26, 2024
04cdc01
Update tidb-lightning/tidb-lightning-logical-import-mode-usage.md
lyzx2001 Apr 26, 2024
a1d076c
Update tidb-lightning/tidb-lightning-error-resolution.md
lyzx2001 Apr 26, 2024
f476588
Update tidb-lightning/tidb-lightning-physical-import-mode-usage.md
lyzx2001 Apr 26, 2024
a07a4e1
update threshold
lyzx2001 Apr 27, 2024
2c5d189
revise threshold
lyzx2001 Apr 28, 2024
7f33da2
revise precheck-conflict-before-import
lyzx2001 Apr 28, 2024
cb41356
revise threshold
lyzx2001 Apr 28, 2024
ab70ad9
Update tidb-lightning/tidb-lightning-configuration.md
lyzx2001 Apr 29, 2024
a0813f2
Update tidb-lightning/tidb-lightning-configuration.md
lyzx2001 May 6, 2024
00c53bb
Update tidb-lightning/tidb-lightning-physical-import-mode-usage.md
lyzx2001 May 6, 2024
22409cd
Apply suggestions from code review
qiancai May 7, 2024
29fb9e5
update performance
lyzx2001 May 13, 2024
593bc73
update performance
lyzx2001 May 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions tidb-lightning/tidb-lightning-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,19 +125,22 @@ driver = "file"
# keep-after-success = false

[conflict]
# Starting from v7.3.0, a new version of strategy is introduced to handle conflicting data. The default value is "". Starting from v8.0.0, TiDB Lightning optimizes the conflict strategy for both physical and logical import modes (experimental).
# Starting from v7.3.0, a new version of strategy is introduced to handle conflicting data. The default value is "". Starting from v8.0.0, TiDB Lightning optimizes the conflict strategy for both physical and logical import modes.
# - "": in the physical import mode, TiDB Lightning does not detect or handle conflicting data. If the source file contains conflicting primary or unique key records, the subsequent step reports an error. In the logical import mode, TiDB Lightning converts the "" strategy to the "error" strategy for processing.
# - "error": when detecting conflicting primary or unique key records in the imported data, TiDB Lightning terminates the import and reports an error.
# - "replace": when encountering conflicting primary or unique key records, TiDB Lightning retains the latest data and overwrites the old data.
# The conflicting data are recorded in the `lightning_task_info.conflict_error_v2` table (recording conflicting data detected by post-import conflict detection in the physical import mode) and the `conflict_records` table (recording conflicting data detected by preprocess conflict detection in both logical and physical import modes) of the target TiDB cluster.
# If you set `conflict.strategy = "replace"` in physical import mode, the conflicting data can be checked in `lightning_task_info.conflict_view` view.
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
# If you set `conflict.strategy = "replace"` in physical import mode, the conflicting data can be checked in `lightning_task_info.conflict_view` view.
# If you set `conflict.strategy = "replace"` in physical import mode, the conflicting data can be checked in the `lightning_task_info.conflict_view` view.

Copy link
Collaborator

@qiancai qiancai Apr 25, 2024

Choose a reason for hiding this comment

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

Is "conflict_view" a table? If yes, can we use "the lightning_task_info.conflict_view table" instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, "conflict_view" is a view

# You can manually insert the correct records into the target table based on your application requirements. Note that the target TiKV must be v5.2.0 or later versions.
# - "ignore": when encountering conflicting primary or unique key records, TiDB Lightning retains the old data and ignores the new data. This option can only be used in the logical import mode.
strategy = ""
# Controls whether to enable preprocess conflict detection, which checks conflicts in data before importing it to TiDB. In scenarios where the ratio of conflict records is greater than or equal to 1%, it is recommended to enable preprocess conflict detection for better performance in conflict detection. In other scenarios, it is recommended to disable it. The default value is false, indicating that TiDB Lightning only checks conflicts after the import. If you set it to true, TiDB Lightning checks conflicts both before and after the import. This parameter is experimental, and it can be used only in the physical import mode.
# Controls whether to enable preprocess conflict detection, which checks conflicts in data before importing it to TiDB. In scenarios where the ratio of conflict records is greater than or equal to 1%, it is recommended to set `precheck-conflict-before-import = true` for better performance in conflict detection. In other scenarios, it is recommended to disable it. The default value is false, indicating that TiDB Lightning only checks conflicts after the import. If you set it to true, TiDB Lightning checks conflicts both before and after the import. This parameter can be used only in the physical import mode.
# precheck-conflict-before-import = false
# Controls the maximum number of conflict errors that can be handled when the strategy is "replace" or "ignore". You can set it only when the strategy is "replace" or "ignore". The default value is 9223372036854775807, which means that almost all errors are tolerant.
# threshold = 9223372036854775807
# Controls the maximum number of records in the `conflict_records` table. The default value is 100. In the physical import mode, if the strategy is "replace", the conflict records that are overwritten are recorded. In the logical import mode, if the strategy is "ignore", the conflict records that are ignored are recorded; if the strategy is "replace", the conflict records are not recorded.
# Controls the maximum number of conflict errors that can be handled when strategy is "replace" or "ignore". You can set it only when strategy is "replace" or "ignore". The default value is 10000.
# threshold = 10000
# Controls the maximum number of records in the `conflict_records` table. The default value is 10000. In the physical import mode, if the strategy is "replace", the conflict records that are overwritten are recorded.
# In the logical import mode, if the strategy is "ignore", the conflict records that are ignored are recorded; if the strategy is "replace", the conflict records are not recorded.
# Starting from v8.1.0, max-record-rows will be assigned the value of threshold, regardless the user input. max-record-rows will be deprecated in the future.
lyzx2001 marked this conversation as resolved.
Show resolved Hide resolved
# max-record-rows = 100
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
# max-record-rows = 100
# max-record-rows = 1000

update it according to L141
image


[tikv-importer]
Expand Down
7 changes: 4 additions & 3 deletions tidb-lightning/tidb-lightning-physical-import-mode-usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ check-requirements = true
data-source-dir = "/data/my_database"

[conflict]
# Starting from v7.3.0, a new version of strategy is introduced to handle conflicting data. The default value is "". Starting from v8.0.0, TiDB Lightning optimizes the conflict strategy for both physical and logical import modes (experimental).
# Starting from v7.3.0, a new version of strategy is introduced to handle conflicting data. The default value is "". Starting from v8.0.0, TiDB Lightning optimizes the conflict strategy for both physical and logical import modes.
# - "": TiDB Lightning does not detect or handle conflicting data. If the source file contains conflicting primary or unique key records, the subsequent step reports an error.
# - "error": when detecting conflicting primary or unique key records in the imported data, TiDB Lightning terminates the import and reports an error.
# - "replace": when encountering conflicting primary or unique key records, TiDB Lightning retains the latest data and overwrites the old data.
# The conflicting data are recorded in the `lightning_task_info.conflict_error_v2` table (recording conflicting data detected by post-import conflict detection) and the `conflict_records` table (recording conflicting data detected by preprocess conflict detection) of the target TiDB cluster.
# If you set `conflict.strategy = "replace"` in physical import mode, the conflicting data can be checked in `lightning_task_info.conflict_view` view.
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
# If you set `conflict.strategy = "replace"` in physical import mode, the conflicting data can be checked in `lightning_task_info.conflict_view` view.
# If you set `conflict.strategy = "replace"` in physical import mode, the conflicting data can be checked in the `lightning_task_info.conflict_view` view.

# You can manually insert the correct records into the target table based on your application requirements. Note that the target TiKV must be v5.2.0 or later versions.
strategy = ""
# Controls whether to enable preprocess conflict detection, which checks conflicts in data before importing it to TiDB. In scenarios where the ratio of conflict records is greater than or equal to 1%, it is recommended to enable preprocess conflict detection for better performance in conflict detection. In other scenarios, it is recommended to disable it. The default value is false, indicating that TiDB Lightning only checks conflicts after the import. If you set it to true, TiDB Lightning checks conflicts both before and after the import. This parameter is experimental.
# Controls whether to enable preprocess conflict detection, which checks conflicts in data before importing it to TiDB. In scenarios where the ratio of conflict records is greater than or equal to 1%, it is recommended to set `precheck-conflict-before-import = true` for better performance in conflict detection. In other scenarios, it is recommended to disable it. The default value is false, indicating that TiDB Lightning only checks conflicts after the import. If you set it to true, TiDB Lightning checks conflicts both before and after the import.
lyzx2001 marked this conversation as resolved.
Show resolved Hide resolved
# precheck-conflict-before-import = false
# threshold = 9223372036854775807
# threshold = 10000
lyzx2001 marked this conversation as resolved.
Show resolved Hide resolved
# max-record-rows = 100
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
# max-record-rows = 100
# max-record-rows = 1000


qiancai marked this conversation as resolved.
Show resolved Hide resolved
[tikv-importer]
qiancai marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading