Skip to content

br: cannot restore physically user table if column count mismatch#67541

Open
Leavrth wants to merge 1 commit intopingcap:masterfrom
Leavrth:cannot_restore_physically_user_table_if_column_count_mismatch
Open

br: cannot restore physically user table if column count mismatch#67541
Leavrth wants to merge 1 commit intopingcap:masterfrom
Leavrth:cannot_restore_physically_user_table_if_column_count_mismatch

Conversation

@Leavrth
Copy link
Copy Markdown
Contributor

@Leavrth Leavrth commented Apr 3, 2026

…smatch

What problem does this PR solve?

Issue Number: ref #60930

Problem Summary:
cannot restore physically user table if column count mismatch. Otherwise, the user table schema will be replaced by old version.

What changed and how does it work?

restore user table by SQL if column count mismatch.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced privilege table compatibility verification during restore operations to correctly handle missing columns in system tables, improving the reliability of system table physical restoration decisions.

…smatch

Signed-off-by: Jianjun Liao <jianjun.liao@outlook.com>
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-tests-checked release-note-none Denotes a PR that doesn't merit a release note. labels Apr 3, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai bot commented Apr 3, 2026

Review Complete

Findings: 0 issues
Posted: 0
Duplicates/Skipped: 0

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 3, 2026
@tiprow
Copy link
Copy Markdown

tiprow bot commented Apr 3, 2026

Hi @Leavrth. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 3, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 4aab4587-2eea-4019-9807-20ce1bba1130

📥 Commits

Reviewing files that changed from the base of the PR and between ee3439d and a4d673d.

📒 Files selected for processing (4)
  • br/pkg/restore/snap_client/client.go
  • br/pkg/restore/snap_client/systable_restore.go
  • br/pkg/restore/snap_client/systable_restore_test.go
  • br/pkg/task/restore.go

📝 Walkthrough

Walkthrough

The changes fix typos and rename methods in the SnapClient package for privilege table collation compatibility checking. Method names and corresponding call sites are updated to correct "Compatiblity" to "Compatibility". One logic enhancement improves handling of missing columns in the mysql.user table during schema validation.

Changes

Cohort / File(s) Summary
SnapClient method renames
br/pkg/restore/snap_client/client.go
Renamed field checkPrivilegeTableRowsCollateCompatiblity to privilegeTableRowsCollateCompatibility. Updated public accessor methods: SetCheckPrivilegeTableRowsCollateCompatiblity()SetCheckPrivilegeTableRowsCollateCompatibility() and GetCheckPrivilegeTableRowsCollateCompatiblity()GetCheckPrivilegeTableRowsCollateCompatibility().
Snap client implementation updates
br/pkg/restore/snap_client/systable_restore.go
Renamed internal type and variable: checkPrivilegeTableRowsCollateCompatiblitySQLPaircheckPrivilegeTableRowsCollateCompatibilitySQLPair and collateCompatiblityTableMapcollateCompatibilityTableMap. Updated field references to use new name. Enhanced missing column handling in CheckSysTableCompatibility: for mysql.user table, missing backup columns now force canLoadSysTablePhysical = false instead of failing compatibility.
Test updates
br/pkg/restore/snap_client/systable_restore_test.go
Updated method name call from SetCheckPrivilegeTableRowsCollateCompatiblity(true) to SetCheckPrivilegeTableRowsCollateCompatibility(true). Changed test expectation: "user table in cluster have more columns" scenario now expects canLoadSysTablePhysical == false instead of true.
Restore task updates
br/pkg/task/restore.go
Updated all method calls on SnapClient to use corrected method names: SetCheckPrivilegeTableRowsCollateCompatibility() and GetCheckPrivilegeTableRowsCollateCompatibility() throughout restore client configuration and logic flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Typos corrected with a careful stroke,
Compatiblity → Compatibility, no more joke,
Field names shine, methods align,
Collation checks now perfectly fine!
A hop, skip, and jump to cleaner code! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'br: cannot restore physically user table if column count mismatch' directly reflects the main bug fix in the PR, which prevents physical restoration of the user table when column counts differ.
Description check ✅ Passed The description includes the issue reference (ref #60930), problem summary, solution approach, and completed test checklist. However, it lacks detailed explanation of the implementation and side effect assessments are incomplete.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

Command failed


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Leavrth Leavrth added the needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. label Apr 3, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Apr 3, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: YuJuncen

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 ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Apr 3, 2026
@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Apr 3, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-04-03 03:42:20.039941571 +0000 UTC m=+495745.245301618: ☑️ agreed by YuJuncen.

Copy link
Copy Markdown

@pantheon-ai pantheon-ai 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 looks good. No issues found.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.1196%. Comparing base (864cba9) to head (a4d673d).
⚠️ Report is 147 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #67541        +/-   ##
================================================
- Coverage   77.6911%   77.1196%   -0.5715%     
================================================
  Files          2012       1944        -68     
  Lines        550857     563287     +12430     
================================================
+ Hits         427967     434405      +6438     
- Misses       121174     128803      +7629     
+ Partials       1716         79      -1637     
Flag Coverage Δ
integration 41.0725% <0.0000%> (-7.0834%) ⬇️
unit 76.1566% <62.5000%> (-0.1047%) ⬇️

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

Components Coverage Δ
dumpling 61.5065% <ø> (+4.7091%) ⬆️
parser ∅ <ø> (∅)
br 47.1194% <62.5000%> (-13.8040%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Apr 3, 2026

@Leavrth: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test a4d673d link true /test unit-test

Full PR test history. Your PR dashboard.

Details

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants