Hi all,
I hit a problem these day that sqlalchemy session execute hangs some time.
And if one db operation hangs, all the following operations are blocked...
Here is exception snippet:
ERROR:tornado.application:Uncaught exception, closing connection.
Traceback (most recent call last):
File "/root/workspace/Push Server/server/tornado/iostream.py", line 341,
in wrapper
callback(*args)
File "/root/workspace/Push Server/server/tornado/stack_context.py", line
331, in wrapped
raise_exc_info(exc)
File "/root/workspace/Push Server/server/tornado/stack_context.py", line
302, in wrapped
ret = fn(*args, **kwargs)
File "deviceserver.py", line 241, in send_message
res =
session.execute(connection_writer._table.select().where(connection_writer._table.c.app_key==self.app_key).where(connection_writer._table.c.device_token==self._devicetoken))
File "/root/workspace/Push Server/server/sqlalchemy/orm/scoping.py", line
149, in do
return getattr(self.registry(), name)(*args, **kwargs)
File "/root/workspace/Push Server/server/sqlalchemy/orm/session.py", line
978, in execute
clause, params or {})
File "/root/workspace/Push Server/server/sqlalchemy/engine/base.py", line
717, in execute
return meth(self, multiparams, params)
File "/root/workspace/Push Server/server/sqlalchemy/sql/elements.py",
line 317, in _execute_on_connection
return connection._execute_clauseelement(self, multiparams, params)
File "/root/workspace/Push Server/server/sqlalchemy/engine/base.py", line
814, in _execute_clauseelement
compiled_sql, distilled_params
File "/root/workspace/Push Server/server/sqlalchemy/engine/base.py", line
927, in _execute_context
context)
File "/root/workspace/Push Server/server/sqlalchemy/engine/base.py", line
1076, in _handle_dbapi_exception
exc_info
File "/root/workspace/Push Server/server/sqlalchemy/util/compat.py", line
185, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb)
File "/root/workspace/Push Server/server/sqlalchemy/engine/base.py", line
920, in _execute_context
context)
File "/root/workspace/Push Server/server/sqlalchemy/engine/default.py",
line 425, in do_execute
cursor.execute(statement, parameters)
File "/root/workspace/Push Server/server/pymysql/cursors.py", line 102,
in execute
result = self._query(query)
File "/root/workspace/Push Server/server/pymysql/cursors.py", line 202,
in _query
conn.query(q)
File "/root/workspace/Push Server/server/pymysql/connections.py", line
729, in query
self._affected_rows = self._read_query_result(unbuffered=unbuffered)
File "/root/workspace/Push Server/server/pymysql/connections.py", line
852, in _read_query_result
result.read()
File "/root/workspace/Push Server/server/pymysql/connections.py", line
1055, in read
first_packet = self.connection._read_packet()
File "/root/workspace/Push Server/server/pymysql/connections.py", line
820, in _read_packet
packet = packet_type(self)
File "/root/workspace/Push Server/server/pymysql/connections.py", line
240, in __init__
self._recv_packet(connection)
File "/root/workspace/Push Server/server/pymysql/connections.py", line
246, in _recv_packet
packet_header = connection._read_bytes(4)
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 everytime?
Thanks.
Wesley
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.