diff --git a/executor/infoschema_cluster_table_test.go b/executor/infoschema_cluster_table_test.go index 3633daf1945e2..bdf7ac14235e5 100644 --- a/executor/infoschema_cluster_table_test.go +++ b/executor/infoschema_cluster_table_test.go @@ -290,7 +290,7 @@ func TestTableStorageStats(t *testing.T) { "test 2", )) rows := tk.MustQuery("select TABLE_NAME from information_schema.TABLE_STORAGE_STATS where TABLE_SCHEMA = 'mysql';").Rows() - result := 41 + result := 42 require.Len(t, rows, result) // More tests about the privileges. diff --git a/session/bootstrap.go b/session/bootstrap.go index 3cac07887e86d..eb5923fa84ac2 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -476,6 +476,26 @@ const ( Password text, PRIMARY KEY (Host,User,Password_timestamp ) ) COMMENT='Password history for user accounts' ` + + // CreateTTLTableStatus is a table about TTL task schedule + CreateTTLTableStatus = `CREATE TABLE IF NOT EXISTS mysql.tidb_ttl_table_status ( + table_id bigint(64) PRIMARY KEY, + parent_table_id bigint(64), + table_statistics text DEFAULT NULL, + last_job_id varchar(64) DEFAULT NULL, + last_job_start_time timestamp NULL DEFAULT NULL, + last_job_finish_time timestamp NULL DEFAULT NULL, + last_job_ttl_expire timestamp NULL DEFAULT NULL, + last_job_summary text DEFAULT NULL, + current_job_id varchar(64) DEFAULT NULL, + current_job_owner_id varchar(64) DEFAULT NULL, + current_job_owner_addr varchar(256) DEFAULT NULL, + current_job_owner_hb_time timestamp, + current_job_start_time timestamp NULL DEFAULT NULL, + current_job_ttl_expire timestamp NULL DEFAULT NULL, + current_job_state text DEFAULT NULL, + current_job_status varchar(64) DEFAULT NULL, + current_job_status_update_time timestamp NULL DEFAULT NULL);` ) // bootstrap initiates system DB for a store. @@ -710,6 +730,8 @@ const ( version106 = 106 // version107 add columns related to password expiration into mysql.user version107 = 107 + // version107 adds the table tidb_ttl_table_status + version108 = 108 ) // currentBootstrapVersion is defined as a variable, so we can modify its value for testing. @@ -826,6 +848,7 @@ var ( upgradeToVer105, upgradeToVer106, upgradeToVer107, + upgradeToVer108, } ) @@ -2160,6 +2183,13 @@ func upgradeToVer107(s Session, ver int64) { "ADD COLUMN IF NOT EXISTS `Password_lifetime` SMALLINT UNSIGNED DEFAULT NULL") } +func upgradeToVer108(s Session, ver int64) { + if ver >= version108 { + return + } + doReentrantDDL(s, CreateTTLTableStatus) +} + 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= %?`, @@ -2264,6 +2294,8 @@ func doDDLWorks(s Session) { mustExecute(s, CreatePlanReplayerTaskTable) // Create stats_meta_table_locked table mustExecute(s, CreateStatsTableLocked) + // Create tidb_ttl_table_status table + mustExecute(s, CreateTTLTableStatus) } // inTestSuite checks if we are bootstrapping in the context of tests. diff --git a/session/bootstrap_test.go b/session/bootstrap_test.go index 19c3c71a4a125..f7ced237b0170 100644 --- a/session/bootstrap_test.go +++ b/session/bootstrap_test.go @@ -216,6 +216,9 @@ func TestBootstrapWithError(t *testing.T) { require.Equal(t, 1, row.Len()) require.Equal(t, []byte("True"), row.GetBytes(0)) require.NoError(t, r.Close()) + + // Check tidb_ttl_table_status table + mustExec(t, se, "SELECT * from mysql.tidb_ttl_table_status").Close() } // TestUpgrade tests upgrading