On Mar 1, 2014, at 3:04 AM, Ni Wesley <nisp...@gmail.com> wrote:

>   File "/root/workspace/Push Server/server/pymysql/connections.py", line 829, 
> in _read_bytes
>     "Lost connection to MySQL server during query (%r)" % (e,))
> OperationalError: (OperationalError) (2013, "Lost connection to MySQL server 
> during query (error(110, 'Connection timed out'))") 'SELECT 
> sessions_details.device_token, sessions_details.app_key, 
> sessions_details.create_time, sessions_details.end_time, 
> sessions_details.session_status \nFROM sessions_details \nWHERE 
> sessions_details.app_key = %s AND sessions_details.device_token = %s' 
> (u'e32c72bab0e4d8e225318f98', u'b8066d12-f34d-4464-bff7-7ff6dcd2e196')
> 
> I don't why this happens, actually, the session blocked for about 5 minutes, 
> but mysql server works fine at that moment..is 5 minutes special? Or is there 
> any timeout settings to control session execution timeout?
> 
> Then, I checked the code, and find that, in my whole project, every db 
> operation use the same global session, is this related? I cannot access the 
> code now, but raise the question here for discussion. I see some articles on 
> the net saying, using new created session everytime when db opeation is 
> required.
> 
> Anybody has such expericenc? should I use new created session every time?


does your program use more than one thread?   MySQL connections are not 
threadsafe and you cannot use a single session (which itself refers to just one 
connection at a time) across threads (are you sure you’re not using a 
ScopedSession ?).   the issue looks like a deadlock, which would more likely be 
at the table/row locking level, though I looked up the default timeout for 
MySQL deadlocks and its 50 seconds 
(http://dev.mysql.com/doc/refman/5.0/en/innodb-parameters.html#sysvar_innodb_lock_wait_timeout).

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to