Bug #40635 Client disconnects during each sql call
Submitted: 11 Nov 2008 12:17 Modified: 12 Dec 2008 14:36
Reporter: Van Stokes Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: C API (client library) Severity:S2 (Serious)
Version:5.1.29 OS:Windows (XP Pro x86)
Assigned to: Assigned Account CPU Architecture:Any
Tags: 2013, API, disconnect, query

[11 Nov 2008 12:17] Van Stokes
Description:
We upgraded our MySQL Server from windows x64 5.1.28-rc to x64 5.1.29-rc. We then upgraded our C API from 5.1.22-rc to 5.1.29-rc. Our software client began disconnecting during SQL calls. The error reported by the C API is:

    2013: Lost connection to MySQL server during query

We then have to re-establish the connection.

see forum post: http://forums.mysql.com/read.php?45,228725,228725#msg-228725

We rolled back the API to version 5.1.22-rc and the disconnect problem stopped. BTW, we did NOT roll back the MySQL server. We left it at 5.1.29-rc.

How to repeat:
Not sure. But here is our code (condensed):

	mDatabaseConn = mysql_init( ( MYSQL *) NULL );	// MySQL Init
	if ( !mDatabaseConn )
	{
		LogDebugMessage( __FUNCTION__, "FATAL: Failed to initialize MySQL database connection." );
		DisconnectFromDatabase();
		return false;
	} // mDatabaseConn?
	
	if ( !mysql_real_connect( 
		mDatabaseConn,
		mServerConfig->DBServerAddress,
		mServerConfig->DBServerLogin,
		mServerConfig->DBServerAuthCode,
		NULL,
		mServerConfig->DBServerPortNum,
		NULL,
		CLIENT_MULTI_STATEMENTS|CLIENT_MULTI_RESULTS ) )
	{
		LogDebugMessage( __FUNCTION__, "CRITICAL: MySQL server connection attempt failed." );
		DisconnectFromDatabase();
		return false;
	} // mysql_real_connect?

	// Default the connection to the correct database/schema.
	if ( mysql_select_db( mDatabaseConn, mServerConfig->DBServerCatalog ) < 0 )
	{
		sprintf( mMsg, "CRITICAL: Database/Schema: %s. Select db failed.", mServerConfig->DBServerCatalog );
		LogDebugMessage( __FUNCTION__, mMsg );
		DisconnectFromDatabase();
		return false;
	} // mysql_select_db?

	LogDebugMessage( __FUNCTION__, "NOTICE: Database connected." );

	// Set MySQL options;
	mDatabaseConn->reconnect = 1;		// Enable auto reconnect.
	mysql_autocommit( mDatabaseConn, true );

Suggested fix:
Not sure.
[12 Nov 2008 14:36] MySQL Verification Team
Thank you for the bug report. I did some test on Vista 64-bit without luck to repeat. Would be nice you provide a complete C code test sample, dump of tables involved and the my.ini file. Thanks in advance.
[13 Dec 2008 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".