Skip to content

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

Merged
ti-chi-bot[bot] merged 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-52531-to-release-8.5
Sep 3, 2026
Merged

ti-chi-bot[bot] merged 2 commits 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.
    • Expanded handling for additional metadata, job, timer, TTL, and related system 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

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.

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

Changes

System-table restore filtering

Layer / File(s) Summary
System-table classification
br/pkg/restore/snap_client/systable_restore.go
Adds plan_replayer_status and plan_replayer_task to a dedicated set. Expands the unrecoverable system-table list.
Restore replacement filtering
br/pkg/restore/snap_client/systable_restore.go
Adds isPlanReplayerTables and skips plan replayer tables before unrecoverable-table handling.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

Poem

A rabbit checks the tables in a row,
And skips the ones that should not go.
More system names join the list,
Plan replayers now persist.
Hop, hop—the restore rules grow!

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes completion of the unrecoverable system-table list.
Description check ✅ Passed The description includes the issue, problem, change summary, test selections, impact declarations, documentation status, and release note.
Linked Issues check ✅ Passed The changes complete unrecoverable-table handling and preserve plan replayer support, which aligns with issue #52530.
Out of Scope Changes check ✅ Passed The changes are limited to unrecoverable system-table definitions and plan replayer table 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

@kennytm

kennytm commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

@YuJuncen need to fix the merge conflicts.

Signed-off-by: Juncen Yu <yujuncen@pingcap.com>
@ti-chi-bot

Copy link
Copy Markdown
Member Author

Cherry-pick conflicts appear resolved; removing the do-not-merge/hold label.

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 3, 2026

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

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

35-41: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Correct the plan replayer map name.

planPeplayerTables contains a typo. Rename it to planReplayerTables and update its lookup in isPlanReplayerTables. (raw.githubusercontent.com)

As per coding guidelines, “Go code SHOULD be self-documenting through clear naming and structure.”

Proposed rename
-var planPeplayerTables = map[string]map[string]struct{}{
+var planReplayerTables = map[string]map[string]struct{}{
...
-	tableMap, ok := planPeplayerTables[schemaName]
+	tableMap, ok := planReplayerTables[schemaName]

Also applies to: 324-332

🤖 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 map variable planPeplayerTables to planReplayerTables and update every
reference to it, including the lookup in isPlanReplayerTables; preserve the
existing map contents and behavior.

Source: Coding guidelines

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

Nitpick comments:
In `@br/pkg/restore/snap_client/systable_restore.go`:
- Around line 35-41: Rename the map variable planPeplayerTables to
planReplayerTables and update every reference to it, including the lookup in
isPlanReplayerTables; preserve the existing map contents and behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7a39d9ee-0b6f-4f38-908e-a6b317bc5ac4

📥 Commits

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

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

@codecov

codecov Bot commented Aug 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (release-8.5@b69c871). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.5     #69947   +/-   ##
================================================
  Coverage               ?   56.2363%           
================================================
  Files                  ?       1852           
  Lines                  ?     673319           
  Branches               ?          0           
================================================
  Hits                   ?     378650           
  Misses                 ?     266720           
  Partials               ?      27949           
Flag Coverage Δ
integration 39.8998% <100.0000%> (?)
unit 65.5806% <0.0000%> (?)

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

Components Coverage Δ
dumpling 55.3108% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 64.4319% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

@YuJuncen: Your lgtm message is repeated, so it is ignored.

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.

@ti-chi-bot

ti-chi-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Leavrth, 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-08-03 06:59:29.343351028 +0000 UTC m=+2424955.379446084: ☑️ agreed by YuJuncen.
  • 2026-08-03 07:11:22.691378053 +0000 UTC m=+2425668.727473129: ☑️ agreed by Leavrth.

@kennytm

kennytm commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

/retest

    merge_test.go:112: 
        	Error Trace:	pkg/ddl/tests/indexmerge/merge_test.go:112
        	Error:      	Received unexpected error:
        	            	[domain:8027]Information schema is out of date: schema failed to update in 1 lease, please make sure TiDB can connect to TiKV

@ti-chi-bot
ti-chi-bot Bot merged commit b7657e6 into pingcap:release-8.5 Sep 3, 2026
36 of 40 checks passed
@ti-chi-bot
ti-chi-bot Bot deleted the cherry-pick-52531-to-release-8.5 branch September 3, 2026 07:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. lgtm 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.

4 participants