微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

mysql – 你可以在’将alter table提交到存储引擎’的状态下回滚查询

我们有一个包含7000万行的InnoDB表,我们一直在尝试运行一个alter table语句来修改添加几列.查询似乎已经改变了表,现在处于“将alter table提交到存储引擎”的状态.

START TRANSACTION;
ALTER TABLE table
  MODIFY COLUMN column1 int(11) NOT NULL DEFAULT 0,
  MODIFY COLUMN column2 tinyint(1) NOT NULL DEFAULT 1,
  ADD COLUMN column3 int(11),
  ADD COLUMN column4 int(11) NOT NULL DEFAULT 1,
  ADD COLUMN column5 varchar(255);
COMMIT;

这已经过夜了,现在是19小时.我们没有启用性能架构,因此无法查看估计的完成时间.我担心的是查询正在做什么以及查询是否会在被杀死时回滚.我已经看到其他问题涉及到复制到tmp表或等待表锁的查询.但是,当alter table提交时,我找不到任何关于被卡住的事情.

在此状态下终止查询是否安全,如果查询被终止,它是否会成功回滚?

服务器正在运行MariaDB 10.2

最佳答案:

documentation

Some statements cannot be rolled back. In general, these include data deFinition language (DDL) statements, such as those that create or drop databases, those that create, drop, or alter tables or stored routines.

You should design your transactions not to include such statements. If you issue a statement early in a transaction that cannot be rolled back, and then another statement later fails, the full effect of the transaction cannot be rolled back in such cases by issuing a ROLLBACK statement.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐