首页 > 解决方案 > 更改在生产中运行的 4M+ 条目表上的列

问题描述

我正在尝试在生产中运行的 4M+ 条目表上添加一列phpmyadmin

以下是发生的事情mysql> SHOW FULL PROCESSLIST;

Query   |  670 | copy to tmp table               | ALTER TABLE `table_name`  ADD `new_column` VARCHAR(1) NULL DEFAULT NULL  AFTER `other_column`

Sleep   |  671 |                                 | NULL

[... And here all inserts attempts to that table are stacking ...]

13分钟后崩溃:

200509  0:44:41  InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
InnoDB: Reading tablespace information from the .ibd files...
InnoDB: Restoring possible half-written data pages from the doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to log sequence number 71728461312
InnoDB: Doing recovery: scanned up to log sequence number 71733704192
[...]

如何添加该列... :(

标签: mysqlserver

解决方案


与当前的 16G 相比,分配给 innodb_buffer_pool_size 的内存过多,但也使用了剩余的 2G。

连接使用一定数量的内存。AnALTER TABLE锁定表 rom 插入,因此插入排队,使用更多内存。alter 表使用合理的内存量。

将缓冲池大小减少到 10G 左右可能会提供足够的可用内存。看一个mysqltuner的结果,所以RAM计算。等到服务启动一天左右,然后再查看其他建议。


推荐阅读