Bug #47636 mysql_close dont close connection
Submitted: 24 Sep 2009 22:56 Modified: 25 Sep 2009 5:50
Reporter: Talipov Timur Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S2 (Serious)
Version:mysql-connector-c-6.0.2 OS:Windows (Server 2003 Web Edition)
Assigned to: CPU Architecture:Any
Tags: Connection, mysql_close, mysql_error, socket

[24 Sep 2009 22:56] Talipov Timur
Description:
I greet you, dear developers of MySQL! 
I have a problem. I am writing a mini server for our needs, which should handle up to 60 connections per minute from a single client. Clients will be at least 20 000, and actively work with the database. The fact that my code works with the database is not working correctly. 
Function mysql_close dont close all connection and return error code "MySQL server has gone away"

How to repeat:
	if(mysql_query(&sqlHandle,(PCHAR)&SqlQuery) == 0)
	{
		sqlRes = mysql_store_result( &sqlHandle );
		if(sqlRes != NULL)
		{
			Rows = mysql_num_rows( sqlRes );
			if(Rows == 1)
			{
				while((sqlRow = mysql_fetch_row(sqlRes)))
				{
					Rows = mysql_num_fields(sqlRes);
					dwBalance = atoi((const char *)sqlRow[0]);
				}

				mysql_free_result(sqlRes);
				my_mysql_close(&sqlHandle); // here close conn!
				
				goto end;
			}	else	{
				DbgPrint("-> server_GetLoginBalance. Error. get balance!1 fix it ! %s\n",(PCHAR)&SqlQuery);
				return FALSE;
			}
		}
	}	else	{
		// !mysql_query
		DbgPrint("-> server_GetLoginBalance. Error. Cant do SQL query %s\n",(PCHAR)&SqlQuery);
		goto error_end;
	}

void my_mysql_close(MYSQL *Handle)
{
	PCHAR Error = 0;
	mysql_close(Handle);	
	Error = mysql_error(Handle);
	
	if(Error)
	{
		DbgPrint("my_mysql_close error : %s\n",Error);
	}
}

Suggested fix:
please help me...
[25 Sep 2009 5:50] Sveta Smirnova
We're sorry, but the bug system is not the appropriate forum for asking help on using MySQL products. Your problem looks like not the result of a bug, but wrong settings of max_connections value and/or other resources.

Support on using our products is available both free in our forums at http://forums.mysql.com/ and for a reasonable fee direct from our skilled support engineers at http://www.mysql.com/support/

Thank you for your interest in MySQL.

If you are able to prove this is MySQL bug feel free to reopen the report.