TiDB 执行 Add index 出错后无法撤销

发布于 2021-12-07 12:52:06 字数 4493 浏览 982 评论 2

TiDB 2.0 版本,使用 Ansible 部署, 1台PD Server + TiDB Sever,3台 TiKV Server。

创建表,包含JSON类型字段 player,并用JSON的属性创建虚拟列 vname:

CREATE TABLE players (  
   id INT UNSIGNED NOT NULL primary key auto_increment,
   player JSON NOT NULL,
   vname VARCHAR(50) GENERATED ALWAYS AS (`player` ->> '$.name') NOT NULL
);

插入若干条数据:

insert into players (id,player) values(null,'{"name":"yaoming-1","age":34,"gender":"man","type":"basketBall"}');
insert into players (id,player) values(null,'{"name":"yaoming-2","age":34,"gender":"man","type":"basketBall"}');

......

执行一条 Add Index :

CREATE INDEX `idx_players_vname` ON `players`(`vname`); 

Add Index 语句执行很长时间后,查看日志发现报错:

CREATE INDEX `idx_players_vname` ON `players`(`vname`);
2018/11/19 11:18:40.025 ddl_worker.go:342: [info] [ddl] run DDL job ID:73, Type:add index, State:none, SchemaState:none, SchemaID:1, TableID:69, RowCount:0, ArgLen:0, start time: 2018-11-19 11:18:37.906 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0
2018/11/19 11:18:40.028 index.go:237: [info] [ddl] add index, run DDL job ID:73, Type:add index, State:running, SchemaState:none, SchemaID:1, TableID:69, RowCount:0, ArgLen:4, start time: 2018-11-19 11:18:37.906 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0, index info &model.IndexInfo{ID:1, Name:model.CIStr{O:"idx_players_vname", L:"idx_players_vname"}, Table:model.CIStr{O:"", L:""}, Columns:[]*model.IndexColumn{(*model.IndexColumn)(0xc000d56ab0)}, Unique:false, Primary:false, State:0x0, Comment:"", Tp:1}
2018/11/19 11:18:40.283 domain.go:105: [info] [ddl] diff load InfoSchema from version 57 to 58, in 4.612838ms
2018/11/19 11:18:40.394 ddl_worker.go:476: [info] [ddl] wait latest schema version 58 changed, take time 119.978396ms
2018/11/19 11:18:40.399 ddl_worker.go:342: [info] [ddl] run DDL job ID:73, Type:add index, State:running, SchemaState:delete only, SchemaID:1, TableID:69, RowCount:0, ArgLen:0, start time: 2018-11-19 11:18:37.906 +0800 CST, Err:<nil>, ErrCount:0, SnapshotVersion:0
......

2018/11/19 11:18:43.388 ddl_worker.go:305: [info] [ddl] run DDL job error, sleep a while:1s then retry it.
2018/11/19 11:18:44.388 ddl_worker.go:445: [info] [ddl] schema version doesn't change
2018/11/19 11:18:44.393 ddl_worker.go:342: [info] [ddl] run DDL job ID:73, Type:add index, State:running, SchemaState:write reorganization, SchemaID:1, TableID:69, RowCount:0, ArgLen:0, start time: 2018-11-19 11:18:37.906 +0800 CST, Err:[ddl:-1]Miss column, ErrCount:1, SnapshotVersion:404382684782526466
2018/11/19 11:18:44.398 index.go:965: [info] [ddl-reorg] addTableIndex, job:ID:73, Type:add index, State:running, SchemaState:write reorganization, SchemaID:1, TableID:69, RowCount:0, ArgLen:4, start time: 2018-11-19 11:18:37.906 +0800 CST, Err:[ddl:-1]Miss column, ErrCount:1, SnapshotVersion:404382684782526466, reorgInfo:&ddl.reorgInfo{Job:(*model.Job)(0xc000b9acc0), Handle:1, d:(*ddl.ddl)(0xc0007707e0), first:false}
用 ADMIN CANCEL DDL JOBS 语句取消。但查看日志tidb.log,发现这条DLL JOB 仍在反复执行:

2018/11/19 18:06:09.627 ddl_worker.go:305: [info] [ddl] run DDL job error, sleep a while:1s then retry it.
2018/11/19 18:06:10.627 ddl_worker.go:445: [info] [ddl] schema version doesn't change
2018/11/19 18:06:10.631 ddl_worker.go:342: [info] [ddl] run DDL job ID:73, Type:add index, State:cancelling, SchemaState:write reorganization, SchemaID:1, TableID:69, RowCount:0, ArgLen:0, start time: 2018-11-19 11:18:37.906 +0800 CST, Err:[ddl:-1]Miss column, ErrCount:10659, SnapshotVersion:404382684782526466
2018/11/19 18:06:10.631 ddl_worker.go:350: [info] [ddl] run the cancelling DDL job ID:73, Type:add index, State:cancelling, SchemaState:write reorganization, SchemaID:1, TableID:69, RowCount:0, ArgLen:0, start time: 2018-11-19 11:18:37.906 +0800 CST, Err:[ddl:-1]Miss column, ErrCount:10659, SnapshotVersion:404382684782526466
2018/11/19 18:06:10.634 index.go:965: [info] [ddl-reorg] addTableIndex, job:ID:73, Type:add index, State:cancelling, SchemaState:write reorganization, SchemaID:1, TableID:69, RowCount:0, ArgLen:4, start time: 2018-11-19 11:18:37.906 +0800 CST, Err:[ddl:-1]Miss column, ErrCount:10659, SnapshotVersion:404382684782526466, reorgInfo:&ddl.reorgInfo{Job:(*model.Job)(0xc000dfd140), Handle:1, d:(*ddl.ddl)(0xc000324b60), first:false}

其他的DLL 语句也无法执行,请教应该如何处理?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

成熟稳重的好男人 2021-12-08 02:58:11

“其他的DDL 语句也无法执行”,笔误更正。

无人问我粥可暖 2021-12-07 23:35:28

重新执行初始化命令后,作业回滚撤销成功。

$ ansible-playbook bootstrap.yml

$ ansible-playbook deploy.yml

$ ansible-playbook start.yml

 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文