tadeck / yubico-yubiserve

Automatically exported from code.google.com/p/yubico-yubiserve
GNU General Public License v3.0
0 stars 0 forks source link

Does not reconnect to mysql after session killed #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The code does not attempt to reconnect to MySQL when a session is killed.

This occurs naturally when MySQL kills idle connections, depending on what 
"wait_timeout" is set to
in MySQL.  This by default is 28800 seconds (8 hours).

The issue can be replicated easily by closing the connection used from MySQL.  
After closing the connection, curl
gets "Empty reply from server" as it's outout.

1. Start yubserve, connected to MySQL.

2. In MySQL show the processes, and kill the connection.

mysql> show full processlist \g;
+-----+-------------+-----------+-----------+---------+--------+----------------
-------------------------------------------------------+-----------------------+
| Id  | User        | Host      | db        | Command | Time   | State          
                                                       | Info                  |
+-----+-------------+-----------+-----------+---------+--------+----------------
-------------------------------------------------------+-----------------------+
|   1 | system user |           | NULL      | Connect | 220399 | Has read all 
relay log; waiting for the slave I/O thread to update it | NULL                 
 |
|   2 | system user |           | NULL      | Connect | 220399 | Connecting to 
master                                                  | NULL                  
|
| 266 | yubiserve   | localhost | yubiserve | Sleep   |    385 |                
                                                       | NULL                  |
| 271 | root        | localhost | NULL      | Query   |      0 | NULL           
                                                       | show full processlist |
+-----+-------------+-----------+-----------+---------+--------+----------------
-------------------------------------------------------+-----------------------+
4 rows in set (0.00 sec)

mysql> kill connection 266;
Query OK, 0 rows affected (0.00 sec)

mysql> show full processlist \g;
+-----+-------------+-----------+------+---------+--------+---------------------
--------------------------------------------------+-----------------------+
| Id  | User        | Host      | db   | Command | Time   | State               
                                                  | Info                  |
+-----+-------------+-----------+------+---------+--------+---------------------
--------------------------------------------------+-----------------------+
|   1 | system user |           | NULL | Connect | 220437 | Has read all relay 
log; waiting for the slave I/O thread to update it | NULL                  |
|   2 | system user |           | NULL | Connect | 220437 | Connecting to 
master                                                  | NULL                  
|
| 272 | root        | localhost | NULL | Query   |      0 | NULL                
                                                  | show full processlist |
+-----+-------------+-----------+------+---------+--------+---------------------
--------------------------------------------------+-----------------------+
3 rows in set (0.00 sec)

3. Try a sample query:

11:08:29 [root@OpenGW1 yubiserve]$ curl 
'http://localhost:8000/wsapi/2.0/oathverify?otp=458463&publicid=testtesttest'
curl: (52) Empty reply from server

Original issue reported on code.google.com by glen.ogilvie@gmail.com on 19 Dec 2012 at 10:15

GoogleCodeExporter commented 9 years ago
Commit, rev: 47 

Fixes this, as far as I have tested.

Please can someone QA this change.

Original comment by glen.ogilvie@gmail.com on 20 Dec 2012 at 1:48