Bug #15718 mysql_real_connect() using named pipe doesn't honor wait_timeout
Submitted: 13 Dec 2005 21:22 Modified: 20 Jan 2006 22:40
Reporter: Edmund Mierzwa Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.0.16-nt-max OS:Windows (XP, with SP2)
Assigned to: Paul DuBois CPU Architecture:Any

[13 Dec 2005 21:22] Edmund Mierzwa
Description:
Restarted server with wait_timeout=4.
Then forcing named pipe connection mysql_real_connect( ,".", ) and my idle application does not timeout after exceeding timeout value. If I change "." to "localhost" the app will timeout at the set duration.

Client and server are both at 5.0.16-nt-max.

I could not find any documentation indicating this behaviour or active bugs or mentioned in the windows list.

How to repeat:
[mysqld]
skip-bdb
skip-innodb
skip-ndbcluster
enable-named-pipe
basedir =c:/mysql_5.0
datadir =c:/mysql_5.0/data
language=c:/mysql_5.0/share/english
sql-mode=ANSI_QUOTES,ERROR_FOR_DIVISION_BY_ZERO,IGNORE_SPACE,NO_AUTO_CREATE_USER,NO_BACKSLASH_ESCAPES,NO_ZERO_DATE,NO_ZERO_IN_DATE,PIPES_AS_CONCAT,REAL_AS_FLOAT,STRICT_ALL_TABLES
set-variable = wait_timeout=4
set-variable = interactive_timeout=5

MYSQL *
db_connect(const char *dbname)
{
	my_bool  my_true = true;
	MYSQL *db = mysql_init(NULL);
									if (!db)
		die(db, "mysql_init failed: no memory");

	if (!mysql_real_connect(db, ".", "oven", "xxx", dbname, 0, NULL, CLIENT_MULTI_STATEMENTS ))
		die(db, "mysql_real_connect() failed: %s", mysql_error(db));
	
	return db;
}

Suggested fix:
Behavior for TCPIP and named pipe connection timeouts should be the same.
[13 Dec 2005 23:24] MySQL Verification Team
Changing to documentation category, on Windows the timeout are based
on TCP/IP socket's timeouts that is the reason why behaves in this way.

Thank you for the bug report.
[20 Jan 2006 22:07] MySQL Verification Team
Paul,

The bug report and my comments are limited just for our Windows servers.
The timeouts were implemented using TCP/IP Windows sockets how you
can see below in the piece of code extracted from mysqld.cc 4.1:

#ifdef __WIN__
    /* Set default wait_timeout */
    ulong wait_timeout= global_system_variables.net_wait_timeout * 1000;
    (void) setsockopt(new_sock, SOL_SOCKET, SO_RCVTIMEO, (char*)&wait_timeout,
                    sizeof(wait_timeout));
#endif

so named pipes and shared memory not work with these timeouts just
connections using TCP/IP.

There is a bug report, sorry don't remember the number submited with
a patch how to implement the same kind of timeout on Unices.
[20 Jan 2006 22:40] Paul DuBois
Thank you for your bug report. This issue has been addressed in the
documentation. The updated documentation will appear on our website
shortly, and will be included in the next release of the relevant
product(s).

Additional info:

I'll update the description of wait_timeout here to
indicate that it applies only to TCP/IP connections:

http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html