From 761b5926a73d15ef165f525fdada5a0f7fa3e221 Mon Sep 17 00:00:00 2001 From: glorv Date: Thu, 27 Jun 2024 13:02:52 +0800 Subject: [PATCH] session: reserve bootstrap versions for v8.1.x (#54266) ref pingcap/tidb#53440, close pingcap/tidb#54267 --- .../restore/snap_client/systable_restore_test.go | 2 +- pkg/session/bootstrap.go | 16 ++++++++++------ pkg/session/bootstrap_test.go | 6 +++--- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/br/pkg/restore/snap_client/systable_restore_test.go b/br/pkg/restore/snap_client/systable_restore_test.go index 79ef433ea7399..8fe64402f33c2 100644 --- a/br/pkg/restore/snap_client/systable_restore_test.go +++ b/br/pkg/restore/snap_client/systable_restore_test.go @@ -115,5 +115,5 @@ func TestCheckSysTableCompatibility(t *testing.T) { // // The above variables are in the file br/pkg/restore/systable_restore.go func TestMonitorTheSystemTableIncremental(t *testing.T) { - require.Equal(t, int64(199), session.CurrentBootstrapVersion) + require.Equal(t, int64(209), session.CurrentBootstrapVersion) } diff --git a/pkg/session/bootstrap.go b/pkg/session/bootstrap.go index ce7731c02ddd2..9e50364fd1814 100644 --- a/pkg/session/bootstrap.go +++ b/pkg/session/bootstrap.go @@ -1098,14 +1098,18 @@ const ( // add column `owner_id` for `mysql.tidb_mdl_info` table version198 = 198 - // version 199 + // ... + // [version199, version208] is the version range reserved for patches of 8.1.x + // ... + + // version 209 // sets `tidb_resource_control_strict_mode` to off when a cluster upgrades from some version lower than v8.2. - version199 = 199 + version209 = 209 ) // currentBootstrapVersion is defined as a variable, so we can modify its value for testing. // please make sure this is the largest version -var currentBootstrapVersion int64 = version199 +var currentBootstrapVersion int64 = version209 // DDL owner key's expired time is ManagerSessionTTL seconds, we should wait the time and give more time to have a chance to finish it. var internalSQLTimeout = owner.ManagerSessionTTL + 15 @@ -1269,7 +1273,7 @@ var ( upgradeToVer196, upgradeToVer197, upgradeToVer198, - upgradeToVer199, + upgradeToVer209, } ) @@ -3038,8 +3042,8 @@ func upgradeToVer198(s sessiontypes.Session, ver int64) { doReentrantDDL(s, "ALTER TABLE mysql.tidb_mdl_info ADD COLUMN owner_id VARCHAR(64) NOT NULL DEFAULT '';", infoschema.ErrColumnExists) } -func upgradeToVer199(s sessiontypes.Session, ver int64) { - if ver >= version199 { +func upgradeToVer209(s sessiontypes.Session, ver int64) { + if ver >= version209 { return } diff --git a/pkg/session/bootstrap_test.go b/pkg/session/bootstrap_test.go index f39eefc6545ba..c617f8b83a1d1 100644 --- a/pkg/session/bootstrap_test.go +++ b/pkg/session/bootstrap_test.go @@ -2249,12 +2249,12 @@ func testTiDBUpgradeWithDistTask(t *testing.T, injectQuery string, fatal bool) { require.Equal(t, fatal, fatal2panic) } -func TestTiDBUpgradeToVer199(t *testing.T) { +func TestTiDBUpgradeToVer209(t *testing.T) { ctx := context.Background() store, _ := CreateStoreAndBootstrap(t) defer func() { require.NoError(t, store.Close()) }() - // bootstrap as version198 + // bootstrap as version198, version 199~208 is reserved for v8.1.x bugfix patch. ver198 := version198 seV198 := CreateSessionAndSetID(t, store) txn, err := store.Begin() @@ -2269,7 +2269,7 @@ func TestTiDBUpgradeToVer199(t *testing.T) { require.NoError(t, err) unsetStoreBootstrapped(store.UUID()) - // upgrade to ver199 + // upgrade to ver209 domCurVer, err := BootstrapSession(store) require.NoError(t, err) defer domCurVer.Close()