我正在运行一个Ruby多线程应用程序,它通过互联网收集数据,然后连接到MySQL进行简单的插入:
insert into churches.us values('','NULL','XYZ Christian Church','43.268158','-99.731361','0011111111111','200 N XYZ Ave','Shmack City','Shmack%2CCity','IA',NOW())
在数据库中有大约2600条记录之前,一切都很顺利。 然后一些(不是全部)插入的尝试最终出现在错误中:“MySQL服务器已经消失”。失败的查询看起来很正常,如果我手动运行它们就会起作用。此外,没有慢速查询记录到my.cnf中配置的文件。 mysql.err中没有出现错误。
我无法弄清楚为什么我会收到错误。
服务器上有足够的内存:
free -lmh
total used free shared buffers cached
Mem: 8.8G 1.1G 7.7G 6.4M 94M 162M
Low: 8.8G 1.1G 7.7G
High: 0B 0B 0B
-/+ buffers/cache: 863M 7.9G
Swap: 2.0G 0B 2.0G
select count(*) from churches.us
+----------+
| count(*) |
+----------+
| 2527 |
+----------+
root@fd001:~/test# mysql -u root -p'bleeeeep' -e "show variables like '%wait%';show variables like '%errors%'"
+---------------------------------------------------+----------+
| Variable_name | Value |
+---------------------------------------------------+----------+
| innodb_lock_wait_timeout | 3600 |
| innodb_spin_wait_delay | 6 |
| lock_wait_timeout | 31536000 |
| performance_schema_events_waits_history_long_size | 10000 |
| performance_schema_events_waits_history_size | 10 |
| wait_timeout | 28800 |
+---------------------------------------------------+----------+
+--------------------+---------+
| Variable_name | Value |
+--------------------+---------+
| max_connect_errors | 1000000 |
| slave_skip_errors | OFF |
+--------------------+---------+
root@fd001:~/test# mysql -u root -p'bleeep' -e "show status like '%conn%'; show status like '%thread%'"
+--------------------------+-------+
| Variable_name | Value |
+--------------------------+-------+
| Aborted_connects | 0 |
| Connections | 3105 |
| Max_used_connections | 25 |
| Ssl_client_connects | 0 |
| Ssl_connect_renegotiates | 0 |
| Ssl_finished_connects | 0 |
| Threads_connected | 8 |
+--------------------------+-------+
+------------------------------------------+-------+
| Variable_name | Value |
+------------------------------------------+-------+
| Delayed_insert_threads | 0 |
| Performance_schema_thread_classes_lost | 0 |
| Performance_schema_thread_instances_lost | 0 |
| Slow_launch_threads | 0 |
| Threads_cached | 8 |
| Threads_connected | 8 |
| Threads_created | 83 |
| Threads_running | 2 |
+------------------------------------------+-------+
key_buffer = 128M
max_allowed_packet = 256M
max_connect_errors = 1000000
thread_stack = 192K
thread_cache_size = 16
max_connections = 1024
table_cache = 256
thread_concurrency = 1024
root@fd001:~/test# cat /proc/version
Linux version 3.13.0-40-generic (buildd@comet) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #69- Ubuntu SMP Thu Nov 13 17:53:56 UTC 2014
root@fd001:~/test# ruby -v
ruby 2.1.4p265 (2014-10-27 revision 48166) [x86_64-linux]