Skip to content

br: complete the list of unrecoverable tables (#52531)#69947

Open
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-52531-to-release-8.5
Open

br: complete the list of unrecoverable tables (#52531)#69947
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-52531-to-release-8.5

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Jul 20, 2026

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #52531

What problem does this PR solve?

Issue Number: close #52530

Problem Summary:
we need to complete the list of unrecoverable tables.

What changed and how does it work?

complete the list of unrecoverable tables.

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
    • Improved snapshot restoration handling for internal system tables.
    • Added safeguards to skip system tables that cannot be safely restored.
    • Updated restoration behavior for plan replayer status and task tables.
    • Improved temporary-table replacement during system-table restoration.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Jul 20, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
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.

@ti-chi-bot

Copy link
Copy Markdown
Member Author

@Leavrth This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

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 ti-community-infra/tichi repository.

@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign 3pointer for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

System-table restore logic adds plan replayer table classification, expands unrecoverable-table filtering, and skips plan replayer tables during temporary-table replacement. The helper section contains unresolved merge-conflict markers.

Changes

System-table restore filtering

Layer / File(s) Summary
System-table classification
br/pkg/restore/snap_client/systable_restore.go
Adds plan replayer tables to a dedicated set and expands the unrecoverable system-table list.
Restore replacement filtering
br/pkg/restore/snap_client/systable_restore.go
Adds plan replayer skipping to temporary-table replacement, while leaving merge-conflict markers in the helper section.

Estimated code review effort: 3 (Moderate) | ~15–30 minutes

Suggested reviewers: yujuncen, leavrth, wjhuang2016

Poem

A rabbit found two tables in the snow,
And taught the restore path where not to go.
Old system names joined the skip parade,
While conflict marks remained unafraid.
Hop, hop—may the merge soon be made!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The changes address unrecoverable tables, but unresolved merge-conflict markers and no clear backup-stage filter evidence mean #52530 isn't fully satisfied. Resolve the merge conflicts, then verify the backup-stage filter and recoverable-table handling fully match #52530.
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 (3 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and clearly summarizes the main change: completing the unrecoverable-table list.
Description check ✅ Passed The description includes the required issue number, problem summary, change summary, tests, side effects, docs, and release note sections.
Out of Scope Changes check ✅ Passed No unrelated code paths are introduced; the diff stays focused on system-table restore and plan replayer handling.
✨ 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.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
br/pkg/restore/snap_client/systable_restore.go (1)

315-344: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Resolve merge conflict markers and retain necessary functions.

Unresolved merge conflict markers are causing compilation failures. Since isRenameableSysTable and removeUserResourceGroup are still used elsewhere in the file, they must be preserved alongside the newly introduced plan replayer table helper.

I have additionally renamed the new helper to isPlanReplayerTable (singular) to remain consistent with existing conventions like isUnrecoverableTable, and updated its map reference to planReplayerTables to fix the typo.

🐛 Proposed fix to resolve merge conflicts
-<<<<<<< HEAD
-func isRenameableSysTable(schemaName string, tableName string) bool {
-	tableMap, ok := renameableSysTables[schemaName]
-=======
-func isPlanReplayerTables(schemaName string, tableName string) bool {
-	tableMap, ok := planPeplayerTables[schemaName]
->>>>>>> 4b98d4e74c0 (br: complete the list of unrecoverable tables (`#52531`))
-	if !ok {
-		return false
-	}
-	_, ok = tableMap[tableName]
-	return ok
-}
-
-<<<<<<< HEAD
-func removeUserResourceGroup(ctx context.Context, dbName string, execSQL func(context.Context, string) error) error {
-	sql := fmt.Sprintf("UPDATE %s SET User_attributes = JSON_REMOVE(User_attributes, '$.resource_group');",
-		utils.EncloseDBAndTable(dbName, sysUserTableName))
-	if err := execSQL(ctx, sql); err != nil {
-		// FIXME: find a better way to check the error or we should check the version here instead.
-		if !strings.Contains(err.Error(), "Unknown column 'User_attributes' in 'field list'") {
-			return err
-		}
-		log.Warn("remove resource group meta failed, please ensure target cluster is newer than v6.6.0", logutil.ShortError(err))
-	}
-	return nil
-}
-
-=======
->>>>>>> 4b98d4e74c0 (br: complete the list of unrecoverable tables (`#52531`))
+func isRenameableSysTable(schemaName string, tableName string) bool {
+	tableMap, ok := renameableSysTables[schemaName]
+	if !ok {
+		return false
+	}
+	_, ok = tableMap[tableName]
+	return ok
+}
+
+func isPlanReplayerTable(schemaName string, tableName string) bool {
+	tableMap, ok := planReplayerTables[schemaName]
+	if !ok {
+		return false
+	}
+	_, ok = tableMap[tableName]
+	return ok
+}
+
+func removeUserResourceGroup(ctx context.Context, dbName string, execSQL func(context.Context, string) error) error {
+	sql := fmt.Sprintf("UPDATE %s SET User_attributes = JSON_REMOVE(User_attributes, '$.resource_group');",
+		utils.EncloseDBAndTable(dbName, sysUserTableName))
+	if err := execSQL(ctx, sql); err != nil {
+		// FIXME: find a better way to check the error or we should check the version here instead.
+		if !strings.Contains(err.Error(), "Unknown column 'User_attributes' in 'field list'") {
+			return err
+		}
+		log.Warn("remove resource group meta failed, please ensure target cluster is newer than v6.6.0", logutil.ShortError(err))
+	}
+	return nil
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@br/pkg/restore/snap_client/systable_restore.go` around lines 315 - 344,
Resolve the conflict markers in this section and retain all required functions:
keep isRenameableSysTable and removeUserResourceGroup, while also adding the new
helper as isPlanReplayerTable. Update that helper to reference the correctly
named planReplayerTables map, preserving each function’s existing behavior and
ensuring no merge markers remain.

Source: Pipeline failures

🧹 Nitpick comments (2)
br/pkg/restore/snap_client/systable_restore.go (2)

35-41: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Fix typographical error in the variable name.

The variable name planPeplayerTables contains a typo. Consider renaming it to planReplayerTables for clarity and correctness.

♻️ Proposed refactor
-var planPeplayerTables = map[string]map[string]struct{}{
+var planReplayerTables = map[string]map[string]struct{}{
 	"mysql": {
 		"plan_replayer_status": {},
 		"plan_replayer_task":   {},
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@br/pkg/restore/snap_client/systable_restore.go` around lines 35 - 41, Rename
the package-level variable planPeplayerTables to planReplayerTables and update
every reference to it consistently, preserving the existing table mappings and
behavior.

524-527: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Update the function call to match the renamed helper.

If you accept the renaming suggestion above, be sure to update the invocation here to use the singular isPlanReplayerTable.

♻️ Proposed refactor
-	if isPlanReplayerTables(dbName, tableName) {
+	if isPlanReplayerTable(dbName, tableName) {
 		return nil
 	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@br/pkg/restore/snap_client/systable_restore.go` around lines 524 - 527,
Update the helper invocation in the restore flow to use the renamed singular
symbol isPlanReplayerTable instead of isPlanReplayerTables, preserving the
existing early return behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@br/pkg/restore/snap_client/systable_restore.go`:
- Around line 315-344: Resolve the conflict markers in this section and retain
all required functions: keep isRenameableSysTable and removeUserResourceGroup,
while also adding the new helper as isPlanReplayerTable. Update that helper to
reference the correctly named planReplayerTables map, preserving each function’s
existing behavior and ensuring no merge markers remain.

---

Nitpick comments:
In `@br/pkg/restore/snap_client/systable_restore.go`:
- Around line 35-41: Rename the package-level variable planPeplayerTables to
planReplayerTables and update every reference to it consistently, preserving the
existing table mappings and behavior.
- Around line 524-527: Update the helper invocation in the restore flow to use
the renamed singular symbol isPlanReplayerTable instead of isPlanReplayerTables,
preserving the existing early return behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c5114be5-ac12-4224-8bb2-90f30324103a

📥 Commits

Reviewing files that changed from the base of the PR and between b69c871 and cbc50ad.

📒 Files selected for processing (1)
  • br/pkg/restore/snap_client/systable_restore.go

@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

@ti-chi-bot: The following tests 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/check_dev_2 cbc50ad link true /test check-dev2
idc-jenkins-ci-tidb/check_dev cbc50ad link true /test check-dev
idc-jenkins-ci-tidb/unit-test cbc50ad link true /test unit-test
idc-jenkins-ci-tidb/mysql-test cbc50ad link true /test mysql-test
pull-br-integration-test cbc50ad link true /test pull-br-integration-test
idc-jenkins-ci-tidb/build cbc50ad link true /test build

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

do-not-merge/cherry-pick-not-approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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. 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.

2 participants