Skip to content

dm: fix validator handling for unsigned columns (#12554)#12555

Merged
ti-chi-bot[bot] merged 2 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-12554-to-release-8.5
Mar 15, 2026
Merged

dm: fix validator handling for unsigned columns (#12554)#12555
ti-chi-bot[bot] merged 2 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-12554-to-release-8.5

Conversation

@ti-chi-bot
Copy link
Member

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 adjustValueFromBinlogData before building RowChange, so UNSIGNED values follow the same conversion path as syncer.
This prevents high-bit UNSIGNED values from being treated as negative signed integers during row key generation and downstream validation.
A regression test is added for an int unsigned primary key case.

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?

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

Fixed false-positive DM validator errors on UNSIGNED columns by normalizing row values before validation.

@ti-chi-bot ti-chi-bot added area/dm Issues or PRs related to DM. lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 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 Mar 13, 2026
@gemini-code-assist
Copy link

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 resolves an issue in the DM validator where UNSIGNED integer columns could lead to false-positive validation errors. By integrating a value normalization step, the validator now processes these values consistently with how the syncer handles them, ensuring accurate data comparison and preventing misinterpretation of large unsigned numbers as negative signed ones. This enhancement improves the robustness and reliability of data validation within the DM system.

Highlights

  • Unsigned Column Validation Fix: The DM validator now correctly handles UNSIGNED columns by normalizing row images.
  • Consistent Value Conversion: Row images are adjusted using adjustValueFromBinlogData to ensure UNSIGNED values follow the same conversion path as the syncer.
  • Prevention of Negative Interpretation: This change prevents high-bit UNSIGNED values from being incorrectly treated as negative signed integers during row key generation and validation.
  • Regression Test Added: A new regression test specifically for an int unsigned primary key case was introduced.

🧠 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
  • dm/syncer/data_validator.go
    • Added calls to adjustValueFromBinlogData for both beforeImage and afterImage within the processRowsEvent function.
  • dm/syncer/data_validator_test.go
    • Introduced TestValidatorProcessRowsEventAdjustUnsignedData to test the validator's behavior with unsigned integer data, including assertions for correct key generation and value interpretation.
Activity
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.

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

  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.

Copy link
Contributor

@Benjamin2037 Benjamin2037 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 bot added the approved label Mar 13, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Mar 13, 2026

[APPROVALNOTIFIER] This PR is APPROVED

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

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
Copy link
Contributor

ti-chi-bot bot commented Mar 13, 2026

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

@codecov
Copy link

codecov bot commented Mar 13, 2026

Codecov Report

❌ Patch coverage is 40.00000% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.5@95dba8c). Learn more about missing BASE report.

Additional details and impacted files
Components Coverage Δ
cdc 57.5838% <0.0000%> (?)
dm 48.7546% <0.0000%> (?)
engine 50.7332% <0.0000%> (?)
Flag Coverage Δ
cdc 57.5838% <ø> (?)
unit 53.3437% <40.0000%> (?)

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

@@               Coverage Diff                @@
##             release-8.5     #12555   +/-   ##
================================================
  Coverage               ?   53.3437%           
================================================
  Files                  ?       1026           
  Lines                  ?     137332           
  Branches               ?          0           
================================================
  Hits                   ?      73258           
  Misses                 ?      58615           
  Partials               ?       5459           
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@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 fixes an issue where unsigned integer columns were not handled correctly by the DM validator, leading to false-positive errors. The change involves normalizing row images using adjustValueFromBinlogData before validation, aligning the validator's behavior with the syncer. A regression test for an int unsigned primary key has been added to verify the fix. The changes look good, but I have a suggestion to improve code readability by reducing some duplication.

Comment on lines +929 to +940
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")
}
}

Choose a reason for hiding this comment

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

medium

The logic for adjusting beforeImage and afterImage is duplicated. While this is a small duplication, we can make it more concise and reduce redundancy by creating a helper function. This would also make the code easier to maintain in the future.

@wuhuizuo
Copy link
Contributor

/retest

@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 Mar 13, 2026
@EmmaDuDu
Copy link

/retest

@ti-chi-bot ti-chi-bot bot merged commit b02e92d into pingcap:release-8.5 Mar 15, 2026
23 checks passed
@ti-chi-bot ti-chi-bot bot deleted the cherry-pick-12554-to-release-8.5 branch March 15, 2026 06:36
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/M Denotes a PR that changes 30-99 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