我正在尝试将自动增量列添加到mysql表中,如下所示:
mysql> ALTER TABLE scraped_comments ADD row_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY;
该表中大约有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
...
感谢您的帮助
答案 0 :(得分:0)
跨越
MySQL: InnoDb: Semaphore wait has lasted > 600 seconds. We intentionally crash the server
并增加了thread_cache_size,innodb_buffer_pool_size和table_open_cache。我想这个问题是由于innodb_buffer_size造成的,因为我第一次尝试使用2 GB的innodb_buffer_size无效。然后将其增加到3 GB,查询成功完成