更改 TABLE:错误 2013 (HY000):查询期间与 MySQL 服务器失去连接
ALTER TABLE: ERROR 2013 (HY000): Lost connection to MySQL server during query
我正在尝试将自动递增列添加到 mysql table 为:
mysql> ALTER TABLE scraped_comments ADD row_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY;
table 中大约有 1500 万条记录。查询运行了大约一个半小时,然后以错误结束:
错误 2013 (HY000):查询期间与 MySQL 服务器失去连接
我尝试通过编辑 /etc/mysql/mysql.conf.d/mysqld.cnf 来设置更高的超时值
wait_timeout = 31536000
interactive_timeout = 31536000
然后 运行 再次查询。但是错误仍然存在。虽然查询是 运行,但我认为问题可能是由内存不足引起的,所以我在另一个终端打开了 htop,但使用的内存不到一半。
我检查了 /var/log/mysql/error.log 文件并在该文件中发现以下内容:
...
InnoDB: ###### Diagnostic info printed to the standard error stream
2019-06-14T06:21:49.965496Z 0 [ERROR] [MY-012872] [InnoDB] Semaphore wait has lasted > 38632704 seconds. We intentionally crash the server because it appears to be hung.[FATAL] Semaphore wait has lasted > 600 seconds. We intentionally crash the server because it appears to be hung.
2019-06-14T06:21:49.965563Z 0 [ERROR] [MY-013183] [InnoDB] Assertion failure: ut0ut.cc:629 thread 140385843095296
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
06:21:49 UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x46000
/usr/sbin/mysqld(my_print_stacktrace(unsigned char*, unsigned long)+0x3d) [0x1dc2f5d]
/usr/sbin/mysqld(handle_fatal_signal+0x351) [0xeee441]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390) [0x7fae50d4f390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7fae4f241428]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7fae4f24302a]
/usr/sbin/mysqld(ut_dbg_assertion_failed(char const*, char const*, unsigned long)+0x2db) [0x20736cb]
/usr/sbin/mysqld(ib::fatal::~fatal()+0x18e) [0x2075afe]
/usr/sbin/mysqld(srv_error_monitor_thread()+0xc07) [0x200ccf7]
/usr/sbin/mysqld(std::thread::_Impl<std::_Bind_simple<Runnable (void (*)())> >::_M_run()+0x63) [0x1e6e543]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xb8c80) [0x7fae4fbadc80]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7fae50d456ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7fae4f31341d]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
2019-06-14T06:21:53.867586Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.16) starting as process 6199
2019-06-14T06:21:58.097227Z 0 [System] [MY-010229] [Server] Starting crash recovery...
2019-06-14T06:21:58.114311Z 0 [System] [MY-010232] [Server] Crash recovery finished.
2019-06-14T06:21:59.096291Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-06-14T06:21:59.225066Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.16' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2019-06-14T06:21:59.436191Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
...
感谢您的帮助
遇到了
并增加了thread_cache_size、innodb_buffer_pool_size和table_open_cache。我猜这个问题是由于 innodb_buffer_size 引起的,因为我第一次尝试使用 2 GB 的 innodb_buffer_size 但没有用。然后我将其增加到 3 GB,查询成功完成
我正在尝试将自动递增列添加到 mysql table 为:
mysql> ALTER TABLE scraped_comments ADD row_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY;
table 中大约有 1500 万条记录。查询运行了大约一个半小时,然后以错误结束:
错误 2013 (HY000):查询期间与 MySQL 服务器失去连接
我尝试通过编辑 /etc/mysql/mysql.conf.d/mysqld.cnf 来设置更高的超时值
wait_timeout = 31536000
interactive_timeout = 31536000
然后 运行 再次查询。但是错误仍然存在。虽然查询是 运行,但我认为问题可能是由内存不足引起的,所以我在另一个终端打开了 htop,但使用的内存不到一半。
我检查了 /var/log/mysql/error.log 文件并在该文件中发现以下内容:
...
InnoDB: ###### Diagnostic info printed to the standard error stream
2019-06-14T06:21:49.965496Z 0 [ERROR] [MY-012872] [InnoDB] Semaphore wait has lasted > 38632704 seconds. We intentionally crash the server because it appears to be hung.[FATAL] Semaphore wait has lasted > 600 seconds. We intentionally crash the server because it appears to be hung.
2019-06-14T06:21:49.965563Z 0 [ERROR] [MY-013183] [InnoDB] Assertion failure: ut0ut.cc:629 thread 140385843095296
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
06:21:49 UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
Thread pointer: 0x0
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0 thread_stack 0x46000
/usr/sbin/mysqld(my_print_stacktrace(unsigned char*, unsigned long)+0x3d) [0x1dc2f5d]
/usr/sbin/mysqld(handle_fatal_signal+0x351) [0xeee441]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390) [0x7fae50d4f390]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38) [0x7fae4f241428]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x16a) [0x7fae4f24302a]
/usr/sbin/mysqld(ut_dbg_assertion_failed(char const*, char const*, unsigned long)+0x2db) [0x20736cb]
/usr/sbin/mysqld(ib::fatal::~fatal()+0x18e) [0x2075afe]
/usr/sbin/mysqld(srv_error_monitor_thread()+0xc07) [0x200ccf7]
/usr/sbin/mysqld(std::thread::_Impl<std::_Bind_simple<Runnable (void (*)())> >::_M_run()+0x63) [0x1e6e543]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0xb8c80) [0x7fae4fbadc80]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba) [0x7fae50d456ba]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7fae4f31341d]
The manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
2019-06-14T06:21:53.867586Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.16) starting as process 6199
2019-06-14T06:21:58.097227Z 0 [System] [MY-010229] [Server] Starting crash recovery...
2019-06-14T06:21:58.114311Z 0 [System] [MY-010232] [Server] Crash recovery finished.
2019-06-14T06:21:59.096291Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-06-14T06:21:59.225066Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.16' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2019-06-14T06:21:59.436191Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
...
感谢您的帮助
遇到了
并增加了thread_cache_size、innodb_buffer_pool_size和table_open_cache。我猜这个问题是由于 innodb_buffer_size 引起的,因为我第一次尝试使用 2 GB 的 innodb_buffer_size 但没有用。然后我将其增加到 3 GB,查询成功完成