Bug #66556 Connection attempts alternately fail
Submitted: 27 Aug 2012 19:15 Modified: 18 Dec 2012 19:04
Reporter: Michael Finch Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Proxy: Core Severity:S2 (Serious)
Version:0.8.2, 0.8.3 OS:Linux
Assigned to: CPU Architecture:Any
Tags: alternate, Connection, fail, mysql-proxy

[27 Aug 2012 19:15] Michael Finch
Description:
I am using the lua script from the mysql-proxy github: https://github.com/cwarden/mysql-proxy/blob/master/examples/tutorial-keepalive.lua

Once mysql-proxy reaches min_idle_connections + 1, every attempted connection after that will alternate between failing and succeeding (almost identical to bug #51954)

Here is an example of the issue:

-----------------------------------------------------

[connect_server]                          <--------- first client connects fine
 [1].connected_clients = 0
 [1].idling_connections = 0
 [1].type = 1
 [1].state = 0
 [1] open new connection
[read_query]
 authed backend = 0
 used db = commandconsole

[connect_server]                          <--------- second client connects fine
 [1].connected_clients = 0
 [1].idling_connections = 1
 [1].type = 1
 [1].state = 1
 opening new connection on: 1
[read_query]
 authed backend = 0
 used db = commandconsole

[connect_server]                          <--------- third client connects fine
 [1].connected_clients = 0
 [1].idling_connections = 2
 [1].type = 1
 [1].state = 1
 opening new connection on: 1
[read_query]
 authed backend = 0
 used db = commandconsole

[connect_server]                          <--------- fourth client connects fine at first
 [1].connected_clients = 0
 [1].idling_connections = 3
 [1].type = 1
 [1].state = 1
 using pooled connection from: 1
[disconnect_client]                       <--------- fourth client disconnects automatically

----------------------------

As you can see in the very last line, it automatically disconnects the client. This is the error on the client side:
ERROR 1047 (08S01): Unknown command

The next time I try to connect it will succeed, but the time after that it will fail again. I have tried the old passwords fix but it does not work.

Thanks.

How to repeat:
mysql-5.5.25

-- connection pool
local min_idle_connections = 2
local max_idle_connections = 6

mysql-proxy --proxy-backend-addresses=awef.example.com:3306 --proxy-address=mysql-proxy-test.example.com:3306 --proxy-lua-script=/root/tutorial-keepalive.lua

Connect to MySQL 4 times.

Suggested fix:
The client shouldn't automatically disconnect if there are idle connections available for use.
[18 Dec 2012 19:04] Sveta Smirnova
Thank you for the report.

Verified as described.
[20 Feb 2013 19:09] Sveta Smirnova
Bug #68423 was marked as duplicate of this one.