Bug #29756 MySql .Net Driver unable to retrieve MySql server connection after shutdown
Submitted: 12 Jul 2007 15:20 Modified: 27 Jul 2007 13:24
Reporter: christophe rouz
Status: Verified
Category:Connector/Net Severity:S3 (Non-critical)
Version:5.0.7, 5.2 svn OS:Linux (Debian)
Assigned to: Reggie Burnett Target Version:
Tags: shutdown, server, connector, MySQL
Triage: D1 (Critical)

[12 Jul 2007 15:20] christophe rouz
Description:
Hello,

i had a problem with MySql connector .Net 5.0.7

My application is using this driver, and during a shutdown / restart of the MySql
database server, as my application was still living, it happened that the driver (used in
a pooling way) didn't manage to retrieve the connection to the database after restart : it
raised once "UnableToConnectToHost" exception, then all the following errors were
"TimeoutGettingConnection".

The Semaphore MySqlPool.poolGate was, in fact, never resetted as the last connections
failed into exceptions.

How to repeat:
- Start an app that uses the mysql .net connector, writing often into the database. Here
is my connection string : 

server=192.168.0.1; database=db_name; port=3306; uid=uid; password=password;
pooling=true; charset=utf8; connect timeout=1; min pool size=0; max pool size=100;
connection lifetime=5

- Stop MySql Server

- Restart MySql Server

- Timeout errors should continue to be raised

Suggested fix:
- Just make the poolGate to be resetted after a driver.Open() exception
[27 Jul 2007 13:24] Tonci Grgin
Hi christophe and thanks for your report.

Verified as described. Latest SVN sources produce different error though: "Reading from
stream has failed". Toggling connection reset true/false makes no difference.

Environment:
 - MySQL server 5.0.44BK on WinXP Pro SP2 localhost
 - NET FW 2.0 with latest c/NET sources

    MySqlConnection conn = new MySqlConnection();
    conn.ConnectionString = "server=localhost; database=mysql; port=3306; uid=root;
password=tonchika; pooling=true; charset=utf8; connect timeout=1; min pool size=0; max
pool size=100; connection lifetime=5; connection reset=true";
    conn.Open();
    MySqlCommand cmd = new MySqlCommand();
    cmd.Connection = conn;
    cmd.CommandTimeout = 0;
    cmd.CommandType = CommandType.Text;
    cmd.CommandText = "SELECT 1+1";
    cmd.ExecuteScalar();
//put a BP or dialog here and restart server.
    cmd.CommandText = "SELECT 2+2"; // << Reading from ...
    cmd.ExecuteScalar();
[19 Feb 17:27] Tonci Grgin
Still a bug in 5.2 svn branch against MySQL server 5.1.30GA.
[20 Apr 8:30] Tonci Grgin
Reggie?
[22 Apr 14:21] Tonci Grgin
Since bug is verified ages ago, I rechecked and exception changed (5.2 branch):
"Fatal error encountered during command execution."
[10 Jun 11:42] Tonci Grgin
Bug#38796 was marked as duplicate of this report. Reggie?