Releasing hundreds of connections stuck in TIME_WAIT status
Posted on 2004-10-17
This is with MySQL 4.1 on WinXP and VS 2003 + C# + ADO.NET
After running a series of thousands of queries (no updates) using the OleDb DataReader object, netstat -n shows litterally hundreds of 3306 connections stuck in TIME_WAIT status. This is spite of the fact that I am using only one OleDbConnection object in my code, and consistently calling .Close on each reader I use before it goes out of scope. No threads, just a sequential series of queries.
At some point, programs can't connect anymore. Waiting a minute or two helps and most of these connections seem to time out and get closed.
I've been told that this is caused by a protocol the server uses to make sure "no data was lost in the connection because of a timing between the client and server" (?)
Is there a way to configure MySQL to not keep such connections alive for that long?