Skip to content

Commit

Permalink
bootstrage: reserve bootstrap versions for v7.5.x (#51692)
Browse files Browse the repository at this point in the history
close #51690
  • Loading branch information
okJiang authored Mar 13, 2024
1 parent 36a132b commit e3d74d3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 53 deletions.
2 changes: 1 addition & 1 deletion br/pkg/restore/db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,5 +425,5 @@ func TestGetExistedUserDBs(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(186), session.CurrentBootstrapVersion)
require.Equal(t, int64(195), session.CurrentBootstrapVersion)
}
96 changes: 44 additions & 52 deletions pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,48 +1045,47 @@ const (
// enlarge `VARIABLE_VALUE` of `mysql.global_variables` from `varchar(1024)` to `varchar(16383)`.
version179 = 179

// version 180
// ...
// [version180, version189] is the version range reserved for patches of 7.5.x
// ...

// version 190
// add priority/create_time/end_time to `mysql.tidb_global_task`/`mysql.tidb_global_task_history`
// add concurrency/create_time/end_time/digest to `mysql.tidb_background_subtask`/`mysql.tidb_background_subtask_history`
// add idx_exec_id(exec_id), uk_digest to `mysql.tidb_background_subtask`
// add cpu_count to mysql.dist_framework_meta
version180 = 180
// modify `mysql.dist_framework_meta` host from VARCHAR(100) to VARCHAR(261)
// modify `mysql.tidb_background_subtask`/`mysql.tidb_background_subtask_history` exec_id from varchar(256) to VARCHAR(261)
// modify `mysql.tidb_global_task`/`mysql.tidb_global_task_history` dispatcher_id from varchar(256) to VARCHAR(261)
version190 = 190

// version 181
// version 191
// set tidb_txn_mode to Optimistic when tidb_txn_mode is not set.
version181 = 181
version191 = 191

// version 182
// version 192
// add new system table `mysql.request_unit_by_group`, which is used for
// historical RU consumption by resource group per day.
version182 = 182
version192 = 192

// version 183
// version 193
// replace `mysql.tidb_mdl_view` table
version183 = 183
version193 = 193

// version 184
// version 194
// remove `mysql.load_data_jobs` table
version184 = 184
version194 = 194

// version 185
// version 195
// drop `mysql.schema_index_usage` table
// create `sys` schema
// create `sys.schema_unused_indexes` table
version185 = 185

// version 186
// modify `mysql.dist_framework_meta` host from VARCHAR(100) to VARCHAR(261)
// modify `mysql.tidb_background_subtask` exec_id from varchar(256) to VARCHAR(261)
// modify `mysql.tidb_background_subtask_history` exec_id from varchar(256) to VARCHAR(261)
// modify `mysql.tidb_global_task` dispatcher_id from varchar(256) to VARCHAR(261)
// modify `mysql.tidb_global_task_history` dispatcher_id from varchar(256) to VARCHAR(261)
version186 = 186
version195 = 195
)

// 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 = version186
var currentBootstrapVersion int64 = version195

// 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 @@ -1241,13 +1240,12 @@ var (
upgradeToVer177,
upgradeToVer178,
upgradeToVer179,
upgradeToVer180,
upgradeToVer181,
upgradeToVer182,
upgradeToVer183,
upgradeToVer184,
upgradeToVer185,
upgradeToVer186,
upgradeToVer190,
upgradeToVer191,
upgradeToVer192,
upgradeToVer193,
upgradeToVer194,
upgradeToVer195,
}
)

Expand Down Expand Up @@ -2956,8 +2954,8 @@ func upgradeToVer179(s sessiontypes.Session, ver int64) {
doReentrantDDL(s, "ALTER TABLE mysql.global_variables MODIFY COLUMN `VARIABLE_VALUE` varchar(16383)")
}

func upgradeToVer180(s sessiontypes.Session, ver int64) {
if ver >= version180 {
func upgradeToVer190(s sessiontypes.Session, ver int64) {
if ver >= version190 {
return
}
doReentrantDDL(s, "ALTER TABLE mysql.tidb_global_task ADD COLUMN `priority` INT DEFAULT 1 AFTER `state`", infoschema.ErrColumnExists)
Expand All @@ -2980,10 +2978,16 @@ func upgradeToVer180(s sessiontypes.Session, ver int64) {
doReentrantDDL(s, "ALTER TABLE mysql.tidb_background_subtask ADD UNIQUE INDEX uk_task_key_step_ordinal(task_key, step, ordinal)", dbterror.ErrDupKeyName)

doReentrantDDL(s, "ALTER TABLE mysql.dist_framework_meta ADD COLUMN `cpu_count` INT DEFAULT 0 AFTER `role`", infoschema.ErrColumnExists)

doReentrantDDL(s, "ALTER TABLE mysql.dist_framework_meta MODIFY COLUMN `host` VARCHAR(261)")
doReentrantDDL(s, "ALTER TABLE mysql.tidb_background_subtask MODIFY COLUMN `exec_id` VARCHAR(261)")
doReentrantDDL(s, "ALTER TABLE mysql.tidb_background_subtask_history MODIFY COLUMN `exec_id` VARCHAR(261)")
doReentrantDDL(s, "ALTER TABLE mysql.tidb_global_task MODIFY COLUMN `dispatcher_id` VARCHAR(261)")
doReentrantDDL(s, "ALTER TABLE mysql.tidb_global_task_history MODIFY COLUMN `dispatcher_id` VARCHAR(261)")
}

func upgradeToVer181(s sessiontypes.Session, ver int64) {
if ver >= version181 {
func upgradeToVer191(s sessiontypes.Session, ver int64) {
if ver >= version191 {
return
}
sql := fmt.Sprintf("INSERT HIGH_PRIORITY IGNORE INTO %s.%s VALUES('%s', '%s')",
Expand All @@ -2992,47 +2996,35 @@ func upgradeToVer181(s sessiontypes.Session, ver int64) {
mustExecute(s, sql)
}

func upgradeToVer182(s sessiontypes.Session, ver int64) {
if ver >= version182 {
func upgradeToVer192(s sessiontypes.Session, ver int64) {
if ver >= version192 {
return
}
doReentrantDDL(s, CreateRequestUnitByGroupTable)
}

func upgradeToVer183(s sessiontypes.Session, ver int64) {
if ver >= version183 {
func upgradeToVer193(s sessiontypes.Session, ver int64) {
if ver >= version193 {
return
}
doReentrantDDL(s, CreateMDLView)
}

func upgradeToVer184(s sessiontypes.Session, ver int64) {
if ver >= version184 {
func upgradeToVer194(s sessiontypes.Session, ver int64) {
if ver >= version194 {
return
}
mustExecute(s, "DROP TABLE IF EXISTS mysql.load_data_jobs")
}

func upgradeToVer185(s sessiontypes.Session, ver int64) {
if ver >= version185 {
func upgradeToVer195(s sessiontypes.Session, ver int64) {
if ver >= version195 {
return
}

doReentrantDDL(s, DropMySQLIndexUsageTable)
}

func upgradeToVer186(s sessiontypes.Session, ver int64) {
if ver >= version186 {
return
}

doReentrantDDL(s, "ALTER TABLE mysql.dist_framework_meta MODIFY COLUMN `host` VARCHAR(261)")
doReentrantDDL(s, "ALTER TABLE mysql.tidb_background_subtask MODIFY COLUMN `exec_id` VARCHAR(261)")
doReentrantDDL(s, "ALTER TABLE mysql.tidb_background_subtask_history MODIFY COLUMN `exec_id` VARCHAR(261)")
doReentrantDDL(s, "ALTER TABLE mysql.tidb_global_task MODIFY COLUMN `dispatcher_id` VARCHAR(261)")
doReentrantDDL(s, "ALTER TABLE mysql.tidb_global_task_history MODIFY COLUMN `dispatcher_id` VARCHAR(261)")
}

func writeOOMAction(s sessiontypes.Session) {
comment := "oom-action is `log` by default in v3.0.x, `cancel` by default in v4.0.11+"
mustExecute(s, `INSERT HIGH_PRIORITY INTO %n.%n VALUES (%?, %?, %?) ON DUPLICATE KEY UPDATE VARIABLE_VALUE= %?`,
Expand Down

0 comments on commit e3d74d3

Please sign in to comment.