[Twisted-Python] "MySQL has gone away"
Hi all, I'm using MySQL database in my server app. Pretty often after some inactivity I get this message in my logs "MySQL server has gone away". How can I prevent this? TIA -- Good luck, Pavel Bastov xooChat Evangelist and Team Leader http://www.xoochat.com/
Actually usually it means mysql server died. it's certainly not twisted question, but first of all you need to check mysql logs. 2007/7/26, Pavel Bastov <pbastov@gmail.com>:
Hi all,
I'm using MySQL database in my server app. Pretty often after some inactivity I get this message in my logs "MySQL server has gone away". How can I prevent this?
TIA
-- Good luck,
Pavel Bastov xooChat Evangelist and Team Leader http://www.xoochat.com/
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Aleksey Kishkin
On 7/26/07, Aleksey Kishkin <aleksey.kishkin@gmail.com> wrote:
Actually usually it means mysql server died. it's certainly not twisted question, but first of all you need to check mysql logs.
No, it just means Mysql dropped your connection. By default, MySQL is configured to drop conncetions after a period of inactivity (600 seconds I think). Your client either needs to detect this condition and reconnect, or you can increase the timeout. Arnar
May be. default wait_timeout 8 hours. 2007/7/26, Arnar Birgisson <arnarbi@gmail.com>:
On 7/26/07, Aleksey Kishkin <aleksey.kishkin@gmail.com> wrote:
Actually usually it means mysql server died. it's certainly not twisted question, but first of all you need to check mysql logs.
No, it just means Mysql dropped your connection. By default, MySQL is configured to drop conncetions after a period of inactivity (600 seconds I think). Your client either needs to detect this condition and reconnect, or you can increase the timeout.
Arnar
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Aleksey Kishkin
On Jul 26, 2007, at 6:11 AM, Pavel Bastov wrote:
Hi all,
I'm using MySQL database in my server app. Pretty often after some inactivity I get this message in my logs "MySQL server has gone away". How can I prevent this?
TIA
I've seen this most frequently when I'm dealing with the MySQLdb module directly (i.e., not using twisted.adbapi). It was happening to me when I was trying to use a single cursor throughout my code by passing it around as a property of some object. I believe it has something to do with the weak references used internally in the MySQLdb module (this is just a theory). My solution was to fetch a new cursor in each scope where I needed it, making sure to close it when I was done. Just my 2/100ths.... -phil
2007/7/26, Pavel Bastov <pbastov@gmail.com>:
Hi all,
I'm using MySQL database in my server app. Pretty often after some inactivity I get this message in my logs "MySQL server has gone away". How can I prevent this?
TIA
U can use Mysql::Ping(dbh) to keep the connection alive. ----------- n = mysql::Ping(dbh) Checks whether or not the connection to the server is working. If it has gone down, an automatic reconnection is attempted. Clients that remain idle for a long while, to check whether or not the server has closed the connection and reconnect if necessary can use this function. Returns true if the server is alive and false if an error occurred.
Have you tried cp_reconnect? It solved the problem for me. dbPool = adbapi.ConnectionPool('MySQLdb', db='fee', user='fii', passwd='foo', host='fum', cp_reconnect=True) Cheers, Einar Pavel Bastov wrote:
Hi all,
I'm using MySQL database in my server app. Pretty often after some inactivity I get this message in my logs "MySQL server has gone away". How can I prevent this?
TIA
Hmm, cp_reconnect seems like the proper solution. Thanks for pointing that out to me. On 7/29/07, "Einar S. Idsø" <einar.twisted@norsk-esport.no> wrote:
Have you tried cp_reconnect? It solved the problem for me.
dbPool = adbapi.ConnectionPool('MySQLdb', db='fee', user='fii', passwd='foo', host='fum', cp_reconnect=True)
Cheers, Einar
Pavel Bastov wrote:
Hi all,
I'm using MySQL database in my server app. Pretty often after some inactivity I get this message in my logs "MySQL server has gone away". How can I prevent this?
TIA
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
-- Good luck, Pavel Bastov xooChat Evangelist and Team Leader http://www.xoochat.com/
participants (6)
-
"Einar S. Idsø"
-
Aleksey Kishkin
-
Arnar Birgisson
-
Pavel Bastov
-
Phil Christensen
-
马踏飞燕