Skip to content

Commit

Permalink
bootstrap: Modify column sizes in constant.go and bootstrap.go (#51457)…
Browse files Browse the repository at this point in the history
… (#53064)

close #51445
  • Loading branch information
ti-chi-bot authored May 21, 2024
1 parent 2f7f8e8 commit 7ece220
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
4 changes: 2 additions & 2 deletions pkg/ddl/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const (
task_key varchar(256),
ddl_physical_tid bigint(20),
type int,
exec_id varchar(256),
exec_id varchar(261),
exec_expired timestamp,
state varchar(64) not null,
checkpoint longblob not null,
Expand All @@ -71,7 +71,7 @@ const (
task_key varchar(256),
ddl_physical_tid bigint(20),
type int,
exec_id varchar(256),
exec_id varchar(261),
exec_expired timestamp,
state varchar(64) not null,
checkpoint longblob not null,
Expand Down
29 changes: 25 additions & 4 deletions pkg/session/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ const (
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
task_key VARCHAR(256) NOT NULL,
type VARCHAR(256) NOT NULL,
dispatcher_id VARCHAR(256),
dispatcher_id VARCHAR(261),
state VARCHAR(64) NOT NULL,
start_time TIMESTAMP,
state_update_time TIMESTAMP,
Expand All @@ -588,7 +588,7 @@ const (
id BIGINT(20) NOT NULL AUTO_INCREMENT PRIMARY KEY,
task_key VARCHAR(256) NOT NULL,
type VARCHAR(256) NOT NULL,
dispatcher_id VARCHAR(256),
dispatcher_id VARCHAR(261),
state VARCHAR(64) NOT NULL,
start_time TIMESTAMP,
state_update_time TIMESTAMP,
Expand All @@ -602,7 +602,7 @@ const (

// CreateDistFrameworkMeta create a system table that distributed task framework use to store meta information
CreateDistFrameworkMeta = `CREATE TABLE IF NOT EXISTS mysql.dist_framework_meta (
host VARCHAR(100) NOT NULL PRIMARY KEY,
host VARCHAR(261) NOT NULL PRIMARY KEY,
role VARCHAR(64),
keyspace_id bigint(8) NOT NULL DEFAULT -1);`

Expand Down Expand Up @@ -1024,11 +1024,19 @@ const (
// vresion 179
// enlarge `VARIABLE_VALUE` of `mysql.global_variables` from `varchar(1024)` to `varchar(16383)`.
version179 = 179

// version 180
// 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)
version180 = 180
)

// 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 = version179
var currentBootstrapVersion int64 = version180

// 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 @@ -1183,6 +1191,7 @@ var (
upgradeToVer177,
upgradeToVer178,
upgradeToVer179,
upgradeToVer180,
}
)

Expand Down Expand Up @@ -2897,6 +2906,18 @@ func upgradeToVer179(s Session, ver int64) {
doReentrantDDL(s, "ALTER TABLE mysql.global_variables MODIFY COLUMN `VARIABLE_VALUE` varchar(16383)")
}

func upgradeToVer180(s Session, ver int64) {
if ver >= version180 {
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 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
2 changes: 1 addition & 1 deletion tests/integrationtest/r/session/bootstrap_upgrade.result
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tidb_background_subtask_history CREATE TABLE `tidb_background_subtask_history` (
`task_key` varchar(256) DEFAULT NULL,
`ddl_physical_tid` bigint(20) DEFAULT NULL,
`type` int(11) DEFAULT NULL,
`exec_id` varchar(256) DEFAULT NULL,
`exec_id` varchar(261) DEFAULT NULL,
`exec_expired` timestamp NULL DEFAULT NULL,
`state` varchar(64) NOT NULL,
`checkpoint` longblob NOT NULL,
Expand Down

0 comments on commit 7ece220

Please sign in to comment.