diff --git a/pkg/ddl/constant.go b/pkg/ddl/constant.go index 08da103425174..7c11539e12a2d 100644 --- a/pkg/ddl/constant.go +++ b/pkg/ddl/constant.go @@ -48,7 +48,6 @@ const ( job_meta longblob, type int, processing int, - bdr_role varchar(64), primary key(job_id))` // ReorgTableSQL is the CREATE TABLE SQL of `tidb_ddl_reorg`. ReorgTableSQL = "create table " + ReorgTable + `( @@ -69,7 +68,6 @@ const ( schema_ids text(65535), table_ids text(65535), create_time datetime, - bdr_role varchar(64), primary key(job_id))` // BackgroundSubtaskTableSQL is the CREATE TABLE SQL of `tidb_background_subtask`. BackgroundSubtaskTableSQL = `create table tidb_background_subtask ( diff --git a/pkg/ddl/ddl.go b/pkg/ddl/ddl.go index 76707b739ee84..9d73c832fde6b 100644 --- a/pkg/ddl/ddl.go +++ b/pkg/ddl/ddl.go @@ -1827,12 +1827,11 @@ func addHistoryDDLJob2Table(sess *sess.Session, job *model.Job, updateRawArgs bo return err } _, err = sess.Execute(context.Background(), - fmt.Sprintf("insert ignore into mysql.tidb_ddl_history(job_id, job_meta, db_name, table_name, schema_ids, table_ids, create_time, bdr_role) values (%d, %s, %s, %s, %s, %s, %v, '%s')", + fmt.Sprintf("insert ignore into mysql.tidb_ddl_history(job_id, job_meta, db_name, table_name, schema_ids, table_ids, create_time) values (%d, %s, %s, %s, %s, %s, %v)", job.ID, util.WrapKey2String(b), strconv.Quote(job.SchemaName), strconv.Quote(job.TableName), strconv.Quote(strconv.FormatInt(job.SchemaID, 10)), strconv.Quote(strconv.FormatInt(job.TableID, 10)), strconv.Quote(model.TSConvert2Time(job.StartTS).String()), - job.BDRRole, ), "insert_history") return errors.Trace(err) diff --git a/pkg/ddl/job_table.go b/pkg/ddl/job_table.go index 3a81358c5aeee..2a90b31b41a98 100644 --- a/pkg/ddl/job_table.go +++ b/pkg/ddl/job_table.go @@ -471,7 +471,7 @@ func (d *ddl) getTableByTxn(r autoid.Requirement, schemaID, tableID int64) (*mod } const ( - addDDLJobSQL = "insert into mysql.tidb_ddl_job(job_id, reorg, schema_ids, table_ids, job_meta, type, processing, bdr_role) values" + addDDLJobSQL = "insert into mysql.tidb_ddl_job(job_id, reorg, schema_ids, table_ids, job_meta, type, processing) values" updateDDLJobSQL = "update mysql.tidb_ddl_job set job_meta = %s where job_id = %d" ) @@ -494,7 +494,7 @@ func insertDDLJobs2Table(se *sess.Session, updateRawArgs bool, jobs ...*model.Jo if i != 0 { sql.WriteString(",") } - fmt.Fprintf(&sql, "(%d, %t, %s, %s, %s, %d, %t, '%s')", job.ID, job.MayNeedReorg(), strconv.Quote(job2SchemaIDs(job)), strconv.Quote(job2TableIDs(job)), util.WrapKey2String(b), job.Type, !job.NotStarted(), job.BDRRole) + fmt.Fprintf(&sql, "(%d, %t, %s, %s, %s, %d, %t)", job.ID, job.MayNeedReorg(), strconv.Quote(job2SchemaIDs(job)), strconv.Quote(job2TableIDs(job)), util.WrapKey2String(b), job.Type, !job.NotStarted()) } se.SetDiskFullOpt(kvrpcpb.DiskFullOpt_AllowedOnAlmostFull) ctx := kv.WithInternalSourceType(context.Background(), kv.InternalTxnDDL) diff --git a/pkg/ddl/modify_column_test.go b/pkg/ddl/modify_column_test.go index bb62e2c3a7192..87e2e5f4cb12f 100644 --- a/pkg/ddl/modify_column_test.go +++ b/pkg/ddl/modify_column_test.go @@ -127,7 +127,7 @@ func TestModifyColumnReorgInfo(t *testing.T) { } // check the consistency of the tables. currJobID := strconv.FormatInt(currJob.ID, 10) - tk.MustQuery("select job_id, reorg, schema_ids, table_ids, type, processing, bdr_role from mysql.tidb_ddl_job where job_id = " + currJobID).Check(testkit.Rows()) + tk.MustQuery("select job_id, reorg, schema_ids, table_ids, type, processing from mysql.tidb_ddl_job where job_id = " + currJobID).Check(testkit.Rows()) tk.MustQuery("select job_id from mysql.tidb_ddl_history where job_id = " + currJobID).Check(testkit.Rows(currJobID)) tk.MustQuery("select job_id, ele_id, ele_type, physical_id from mysql.tidb_ddl_reorg where job_id = " + currJobID).Check(testkit.Rows()) require.NoError(t, sessiontxn.NewTxn(context.Background(), ctx)) diff --git a/pkg/ddl/stat_test.go b/pkg/ddl/stat_test.go index cc43764ed6225..8aaac9d9d913b 100644 --- a/pkg/ddl/stat_test.go +++ b/pkg/ddl/stat_test.go @@ -153,8 +153,8 @@ func addDDLJobs(sess sessiontypes.Session, txn kv.Transaction, job *model.Job) e if err != nil { return err } - _, err = sess.Execute(kv.WithInternalSourceType(context.Background(), kv.InternalTxnDDL), fmt.Sprintf("insert into mysql.tidb_ddl_job(job_id, reorg, schema_ids, table_ids, job_meta, type, processing, bdr_role) values (%d, %t, %s, %s, %s, %d, %t, '%s')", - job.ID, job.MayNeedReorg(), strconv.Quote(strconv.FormatInt(job.SchemaID, 10)), strconv.Quote(strconv.FormatInt(job.TableID, 10)), util.WrapKey2String(b), job.Type, false, job.BDRRole)) + _, err = sess.Execute(kv.WithInternalSourceType(context.Background(), kv.InternalTxnDDL), fmt.Sprintf("insert into mysql.tidb_ddl_job(job_id, reorg, schema_ids, table_ids, job_meta, type, processing) values (%d, %t, %s, %s, %s, %d, %t)", + job.ID, job.MayNeedReorg(), strconv.Quote(strconv.FormatInt(job.SchemaID, 10)), strconv.Quote(strconv.FormatInt(job.TableID, 10)), util.WrapKey2String(b), job.Type, false)) return err } diff --git a/pkg/session/bootstrap.go b/pkg/session/bootstrap.go index c5a62bd2a9be6..508ce3de2687e 100644 --- a/pkg/session/bootstrap.go +++ b/pkg/session/bootstrap.go @@ -1039,17 +1039,13 @@ const ( version180 = 180 // version 181 - // add column `bdr_role` to `mysql.tidb_ddl_job` and `mysql.tidb_ddl_history`. - version181 = 181 - - // version 182 // set tidb_txn_mode to Optimistic when tidb_txn_mode is not set. - version182 = 182 + version181 = 181 ) // 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 = version182 +var currentBootstrapVersion int64 = version181 // 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 @@ -1206,7 +1202,6 @@ var ( upgradeToVer179, upgradeToVer180, upgradeToVer181, - upgradeToVer182, } ) @@ -2949,14 +2944,6 @@ func upgradeToVer181(s sessiontypes.Session, ver int64) { if ver >= version181 { return } - doReentrantDDL(s, "ALTER TABLE mysql.tidb_ddl_job ADD COLUMN `bdr_role` varchar(64)", infoschema.ErrColumnExists) - doReentrantDDL(s, "ALTER TABLE mysql.tidb_ddl_history ADD COLUMN `bdr_role` varchar(64)", infoschema.ErrColumnExists) -} - -func upgradeToVer182(s sessiontypes.Session, ver int64) { - if ver >= version182 { - return - } sql := fmt.Sprintf("INSERT HIGH_PRIORITY IGNORE INTO %s.%s VALUES('%s', '%s')", mysql.SystemDB, mysql.GlobalVariablesTable, variable.TiDBTxnMode, variable.OptimisticTxnMode)