Bug #7166 Server crashes when running out of connections
Submitted: 10 Dec 2004 12:10 Modified: 23 Mar 2005 20:40
Reporter: Marko Mäkelä Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S1 (Critical)
Version:5.0.3-bk OS:Linux (GNU/Linux)
Assigned to: Konstantin Osipov CPU Architecture:Any

[10 Dec 2004 12:10] Marko Mäkelä
Description:
When I set max_connections to a low number and start a stress test of
InnoDB/MySQL 5.0.3, I get the following crash:

Program received signal SIGSEGV, Segmentation fault.
0x080c92a7 in thd_increment_bytes_sent ()
(gdb) bt
#0  0x080c92a7 in thd_increment_bytes_sent ()
#1  0x080ce6aa in net_real_write ()
#2  0x080ce4d9 in net_write_command ()
#3  0x080cf299 in net_send_error(THD*, unsigned, char const*) ()
#4  0x080dba13 in create_new_thread(THD*) ()
#5  0x080d89b8 in handle_connections_sockets ()
#6  0x42207630 in ?? ()
#7  0x00000001 in ?? ()

One of the DBI-based test scripts reports:
Got error: '#08004Too many connections' when connecting to DBI:mysql:test;mysql_read_default_file=/home/marko/test-my.cnf with user: '' password: ''

How to repeat:
Start mysqld --max_connections=2 and try to open 4 connections, e.g., "mysql test".
(Yes, it will allow you to open 3 connections without problems. The fourth one
will complain "ERROR 1040 (00000): Too many connections", and mysqld will catch SIGSEGV in thd_increment_bytes_sent().)
[23 Mar 2005 16:42] Konstantin Osipov
I remember this being fixed in 4.1 and can't repeat it any more in 5.0.
Feel free to reopen this report if you can repeat the bug.
[23 Mar 2005 16:44] Konstantin Osipov
Valgrind barks with the following:
=6768==    at 0x824DA9F: push_warning(THD*, MYSQL_ERROR::enum_warning_level, unsigned, char const*) (sql_error.cc:116)
==6768==    by 0x81D030F: net_send_error(THD*, unsigned, char const*) (protocol.cc:103)
==6768==    by 0x81ED9E1: check_user(THD*, enum_server_command, char const*, unsigned, char const*, bool) (sql_parse.cc:364)
==6768==    by 0x81EEFE6: check_connection(THD*) (sql_parse.cc:983)
==6768==    by 0x81EF265: handle_one_connection (sql_parse.cc:1072)
==6768==    by 0x1BA5BAAB: thread_wrapper (vg_libpthread.c:867)
==6768==    by 0xB000F03A: do__quit (vg_scheduler.c:1872)
==6768== warning: Valgrind's pthread_cond_destroy is incomplete
==6768==          (it doesn't check if the cond is waited on)
==6768==          your program may misbehave as a result

From this I conclude there is something we can do about this bug.
[23 Mar 2005 17:44] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/internals/23320
[23 Mar 2005 17:47] Konstantin Osipov
The bug itself is fixed already, this patch just fixes a valgrind warning:
Subject: bk commit - 5.0 tree (konstantin:1.1847) BUG#7166

ChangeSet
  1.1847 05/03/23 20:43:23 konstantin@mysql.com +1 -0
  Fix a valgrind warning spotted while trying to repeat Bug#7166
  "Server crashes when running out of connections"
[23 Mar 2007 3:50] Eric Roberts
We re using 4.1.2 on RHE 3.  The web app is Coldfusion based (Able Commerce shopping cart).  The connection keep climbing and when it hits 100...it crashes.  Is there a patch or anything else we can do to fix this(besides upgrading to 5)?