session: ensure masking policy table before old upgrades#69738
session: ensure masking policy table before old upgrades#69738expxiaoli wants to merge 1 commit into
Conversation
|
[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 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis change fixes a bootstrap upgrade crash by ensuring the ChangesMasking policy table upgrade fix
Estimated code review effort: 2 (Simple) | ~15 minutes Sequence Diagram(s)sequenceDiagram
participant Session
participant upgrade
participant ensureTiDBMaskingPolicyTableBeforeUpgradeDDL
participant metadef
Session->>upgrade: upgrade(s)
upgrade->>upgrade: upgradeToVer99Before(s)
upgrade->>ensureTiDBMaskingPolicyTableBeforeUpgradeDDL: ensureTiDBMaskingPolicyTableBeforeUpgradeDDL(s, ver)
alt ver < version260
ensureTiDBMaskingPolicyTableBeforeUpgradeDDL->>metadef: CreateTiDBMaskingPolicyTable
else ver >= version260
ensureTiDBMaskingPolicyTableBeforeUpgradeDDL-->>upgrade: return
end
upgrade->>upgrade: run reentrant upgrade DDLs (e.g. upgradeToVer190)
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) 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. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #69738 +/- ##
================================================
- Coverage 76.3225% 74.2987% -2.0239%
================================================
Files 2041 2050 +9
Lines 560226 575276 +15050
================================================
- Hits 427579 427423 -156
- Misses 131746 147609 +15863
+ Partials 901 244 -657
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
What problem does this PR solve?
Issue Number: close #69464
Problem Summary:
During rolling upgrade, a newly started TiDB may repeatedly crash in bootstrap upgrade when upgrading from an old bootstrap version.
upgradeToVer190can run reentrantMODIFY COLUMNDDLs beforeupgradeToVer260createsmysql.tidb_masking_policy. However, the masking policy sync path used by ordinary DDL may querymysql.tidb_masking_policy. If the table does not exist yet, the DDL job fails withTable 'mysql.tidb_masking_policy' doesn't exist, and bootstrap upgrade exits fatally.What changed and how does it work?
Before running the versioned bootstrap upgrade loop, this PR ensures
mysql.tidb_masking_policyexists when the stored bootstrap version is older thanversion260.The table is created with
CREATE TABLE IF NOT EXISTS, so the operation is idempotent. This keeps the fix local to bootstrap upgrade ordering and avoids adding long-lived DDL context state.This PR also extends the existing masking policy bootstrap upgrade test to cover upgrading from bootstrap version
189, which reproduces the actual failingupgradeToVer190path. The existing254coverage is kept.Check List
Tests
Executed:
GOPATH="$HOME/go" GOSUMDB=sum.golang.org ./tools/check/failpoint-go-test.sh pkg/session/test/bootstraptest -run 'TestUpgradeVersion260MaskingPolicy/from_version_189' -count=1GOPATH="$HOME/go" GOSUMDB=sum.golang.org ./tools/check/failpoint-go-test.sh pkg/session/test/bootstraptest -run TestUpgradeVersion260MaskingPolicy -count=1GOPATH="$HOME/go" GOSUMDB=sum.golang.org ./tools/check/failpoint-go-test.sh pkg/session -run TestForIssue23387 -count=1GOPATH="$HOME/go" GOSUMDB=sum.golang.org make bazel_prepareGOPATH="$HOME/go" GOSUMDB=sum.golang.org make lintgit diff --checkSide effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit