简体   繁体   English

尝试向MYSQL表添加新列时失去连接

[英]Lost Connection when trying to add new column to MYSQL table

I'm trying to add a column to a mysql table that has over 25 million rows. 我正在尝试向具有超过2500万行的mysql表添加一列。 I am running the sql command 我正在运行sql命令

ALTER TABLE `table_name` ADD COLUMN `column_name` varchar(128) NULL DEFAULT NULL;

This is being run using the mysql command line application. 这是使用mysql命令行应用程序运行的。

Every time i try to run this it takes hours and then i get the error 每次我尝试运行此程序都需要几个小时,然后我得到了错误

ERROR 2013 (HY000): Lost connection to MySQL server during query 错误2013(HY000):在查询过程中失去与MySQL服务器的连接

The database is running in a RDS instance on AWS and checking the monitoring statistics neither the memory or disk space is being exhausted. 该数据库在AWS上的RDS实例中运行,并检查监视统计信息,而内存或磁盘空间均未耗尽。

Is there anything else i can try to add this column to the table? 还有什么我可以尝试将此列添加到表中的吗?

Check your memory usage or, more probably, your disk usage (is there enough free space during the process?). 检查您的内存使用情况,或者更可能是您的磁盘使用情况(在此过程中是否有足够的可用空间?)。 Altering a table may require either a large amount of memory or a copy on disk of your table. 更改表可能需要大量内存或在表的磁盘上进行复制。 Changing the alter algorithm from INPLACE to COPY can be even faster in your particular case. 在您的特定情况下,将更改算法INPLACE更改COPY甚至更快。

You may also be hitting the innodb_online_alter_log_max_size limit, although in that case, only the query should fail, not the entire server. 您可能还达到了innodb_online_alter_log_max_size限制,尽管在这种情况下,只有查询应该失败,而不是整个服务器。 It is possible that the crash may be happening due to the ROLLBACK , and not the operation itself, though. 崩溃可能是由于ROLLBACK而不是操作本身引起的。

Finally, some application configurations or hosting servers cancels a query/http request that is taking too long, I recommend you to execute the same query on the command line client for testing purposes. 最后,某些应用程序配置或托管服务器取消了花费太长时间的查询/ http请求,我建议您在命令行客户端上执行相同的查询,以进行测试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM