数据库

Mysql Delete 大量数据 kill 后 进程长时间 killed 回滚

By karp 3819 Views 4 MIN READ 0 Comments

诶 今天一早就办了个蠢事. 写了个行情收集的脚本.存到mysql中计划是保存3天的数据, 结果没有启动删除脚本....
数据量 9kw 找到脚本后执行了一下....也是醉了 10分钟啥动静都没有. 我就关掉脚本了.
通过下面方法查看 delete

mysql>  select * from information_schema.`PROCESSLIST` where info is not null;

|ID| USER| HOST| DB| COMMAND| TIME| STATE| INFO|
|-|-|-|-|-|-|-|-|
|10845565| xx| xxx:xxx| xx-data |Query| 0| executing| select * from information_schema.PROCESSLIST where info is not null|
|10844901| xx| xxx:xxx| xx-data| Execute| 375| updating| DELETE FROM market_collection_history WHERE created < 1577068173|

观察到进程 kill ID 关掉进程

mysql> kill 10844901

|ID| USER| HOST| DB| COMMAND| TIME| STATE| INFO|
|-|-|-|-|-|-|-|-|
|10845565| xx| xxx:xxx| xx-data| Query| 0| executing| select * from information_schema.PROCESSLIST where info is not null|
|10844901| xx| xxx:xxx| xx-data| Killed| 642| query end|DELETE FROM collection_history WHERE created < 1577068173|

执行完 `Killed` 好久都不结束, 百度了一下 当执行大数据量 `update delete` 写操作了, kill 后回 回滚...... 时间长是应该的 不长是不应该的........

本文由 karp 原创

采用 CC BY-NC-SA 4.0 协议进行许可

转载请注明出处:https://www.ikarp.top/index.php/archives/452.html

标签: mysql

0 评论