dm: fix validator handling for unsigned columns (#12554)#12557
dm: fix validator handling for unsigned columns (#12554)#12557ti-chi-bot wants to merge 2 commits intopingcap:release-8.1from
Conversation
|
This cherry pick PR is for a release branch and has not yet been approved by triage owners. To merge this cherry pick:
DetailsInstructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Summary of ChangesHello, 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 resolves a critical validation issue in DM (Data Migration) when dealing with UNSIGNED columns. By normalizing row values before validation, it prevents false-positive errors caused by high-bit UNSIGNED values being misinterpreted as negative signed integers. The inclusion of a new regression test ensures the fix's long-term stability. Highlights
🧠 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. Changelog
Activity
Using Gemini Code AssistThe 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
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 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in the data validator where unsigned integer columns were not handled correctly. The change introduces a call to adjustValueFromBinlogData to normalize row images before they are processed, ensuring UNSIGNED values are converted correctly. A regression test is also added to cover this specific case. The changes look good, but I have a suggestion to refactor some duplicated code to improve maintainability.
| if beforeImage != nil { | ||
| beforeImage, err = adjustValueFromBinlogData(beforeImage, tableInfo) | ||
| if err != nil { | ||
| return terror.Annotate(err, "failed to adjust row before image") | ||
| } | ||
| } | ||
| if afterImage != nil { | ||
| afterImage, err = adjustValueFromBinlogData(afterImage, tableInfo) | ||
| if err != nil { | ||
| return terror.Annotate(err, "failed to adjust row after image") | ||
| } | ||
| } |
There was a problem hiding this comment.
The logic for adjusting beforeImage and afterImage is duplicated. You can refactor this into a helper function to improve code clarity and maintainability.
adjustImage := func(image []interface{}, imageName string) ([]interface{}, error) {
if image == nil {
return nil, nil
}
adjustedImage, err := adjustValueFromBinlogData(image, tableInfo)
if err != nil {
return nil, terror.Annotate(err, "failed to adjust row "+imageName+" image")
}
return adjustedImage, nil
}
beforeImage, err = adjustImage(beforeImage, "before")
if err != nil {
return err
}
afterImage, err = adjustImage(afterImage, "after")
if err != nil {
return err
}
This is an automated cherry-pick of #12554
What problem does this PR solve?
Issue Number: close #12178
What is changed and how it works?
DM validator now normalizes row images with
adjustValueFromBinlogDatabefore buildingRowChange, soUNSIGNEDvalues follow the same conversion path as syncer.This prevents high-bit
UNSIGNEDvalues from being treated as negative signed integers during row key generation and downstream validation.A regression test is added for an
int unsignedprimary key case.Check List
Tests
Questions
Will it cause performance regression or break compatibility?
No. This only reuses the existing binlog value normalization path in validator.
Do you need to update user documentation, design documentation or monitoring documentation?
No.
Release note