Skip to content

Commit

Permalink
session: reserve bootstrap versions for v8.1.x (#54266)
Browse files Browse the repository at this point in the history
ref #53440, close #54267
  • Loading branch information
glorv authored Jun 27, 2024
1 parent be334af commit 761b592
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion br/pkg/restore/snap_client/systable_restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
16 changes: 10 additions & 6 deletions pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1269,7 +1273,7 @@ var (
upgradeToVer196,
upgradeToVer197,
upgradeToVer198,
upgradeToVer199,
upgradeToVer209,
}
)

Expand Down Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/session/bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down

0 comments on commit 761b592

Please sign in to comment.