Bug #2447 reconnection retry worse than exponential
Submitted: 19 Jan 2004 10:40 Modified: 6 Feb 2004 8:59
Reporter: Mark Tillotson Email Updates:
Status: Closed Impact on me:
Category:Connector / J Severity:S2 (Serious)
Version:all? OS:Linux (Debian Linux)
Assigned to: Mark Matthews CPU Architecture:Any

[19 Jan 2004 10:40] Mark Tillotson
The parameters "initialTimeout" and "maxReconnects" to the Mysql Connector/J
JDBC drivers are misused in the code.

The code correctly retries "maxReconnects" times, but the retry interval
is _squared_ rather than doubled each time.

Thus if you use maxReconnects=4&initialTimeout=60,
the driver waits for 1 minute, then 1 hour, then 60 hours, then 5 months

How to repeat:
Use a URL like


and try taking Mysql down and back up again for 30 seconds, then for 90 seconds.
In the latter case the application can wait for an hour to recover.

Suggested fix:
In com/mysql/jdbc/Connection.java, the line

          timeout = timeout * timeout ;

should be 
          timeout = timeout * 2.0 ;
[6 Feb 2004 8:59] Mark Matthews
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at