Skip to content

Commit

Permalink
ddl: support bdr bwlist (#48776)
Browse files Browse the repository at this point in the history
ref #48519
  • Loading branch information
okJiang authored Dec 28, 2023
1 parent e04d7a8 commit 60d6286
Show file tree
Hide file tree
Showing 28 changed files with 6,406 additions and 4,742 deletions.
5 changes: 5 additions & 0 deletions errors.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,11 @@ error = '''
Job [%v] has already been paused
'''

["ddl:8263"]
error = '''
The operation is not allowed while the bdr role of this cluster is set to %s.
'''

["domain:8027"]
error = '''
Information schema is out of date: schema failed to update in 1 lease, please make sure TiDB can connect to TiKV
Expand Down
32 changes: 29 additions & 3 deletions pkg/ddl/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,37 @@ const (
BackgroundSubtaskHistoryTableID = meta.MaxInt48 - 6

// JobTableSQL is the CREATE TABLE SQL of `tidb_ddl_job`.
JobTableSQL = "create table " + JobTable + "(job_id bigint not null, reorg int, schema_ids text(65535), table_ids text(65535), job_meta longblob, type int, processing int, primary key(job_id))"
JobTableSQL = "create table " + JobTable + `(
job_id bigint not null,
reorg int,
schema_ids text(65535),
table_ids text(65535),
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 + "(job_id bigint not null, ele_id bigint, ele_type blob, start_key blob, end_key blob, physical_id bigint, reorg_meta longblob, unique key(job_id, ele_id, ele_type(20)))"
ReorgTableSQL = "create table " + ReorgTable + `(
job_id bigint not null,
ele_id bigint,
ele_type blob,
start_key blob,
end_key blob,
physical_id bigint,
reorg_meta longblob,
unique key(job_id, ele_id, ele_type(20)))`
// HistoryTableSQL is the CREATE TABLE SQL of `tidb_ddl_history`.
HistoryTableSQL = "create table " + HistoryTable + "(job_id bigint not null, job_meta longblob, db_name char(64), table_name char(64), schema_ids text(65535), table_ids text(65535), create_time datetime, primary key(job_id))"
HistoryTableSQL = "create table " + HistoryTable + `(
job_id bigint not null,
job_meta longblob,
db_name char(64),
table_name char(64),
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 (
id bigint not null auto_increment primary key,
Expand Down
6 changes: 4 additions & 2 deletions pkg/ddl/ddl.go
Original file line number Diff line number Diff line change
Expand Up @@ -1827,11 +1827,13 @@ 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) values (%d, %s, %s, %s, %s, %s, %v)",
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')",
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())),
strconv.Quote(model.TSConvert2Time(job.StartTS).String()),
job.BDRRole,
),
"insert_history")
return errors.Trace(err)
}
Loading

0 comments on commit 60d6286

Please sign in to comment.