mysql - 更改在生产中运行的 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
[...]
如何添加该列... :(
解决方案
与当前的 16G 相比,分配给 innodb_buffer_pool_size 的内存过多,但也使用了剩余的 2G。
连接使用一定数量的内存。AnALTER TABLE
锁定表 rom 插入,因此插入排队,使用更多内存。alter 表使用合理的内存量。
将缓冲池大小减少到 10G 左右可能会提供足够的可用内存。看一个mysqltuner的结果,所以RAM计算。等到服务启动一天左右,然后再查看其他建议。
推荐阅读
- mysql - MYSQL 根据来自 2 个不同表的 2 列排列用户
- apache-spark - 使用 DATE 示例数据填充 pyspark 数据框
- c - 华硕 Tinker board S SPI 主机没有从从机接收数据
- uwp - 如何修复 UWP 应用程序出现应用程序挂起错误?
- mysql - 未知数据类型:“用户”;SQL 语句
- html - 在导航菜单中禁用“寄生”链接行为
- javascript - 在 jekyll markdown 中创建带有前导箭头的文本框
- jmeter - 从 Json 变量中提取值并执行 java 后处理器操作
- python - 在 Dataflow 流式传输管道上捕获 BigQuery HttpBadRequestError
- scala - 将自动递增的值添加到 scala 映射以获取空值