Commit 84ab18f2 authored by Jérome Perrin's avatar Jérome Perrin

Products.ZMySQLDA: reconnect after "commands out of sync" errors

see https://github.com/zopefoundation/Products.ZMySQLDA/commit/c31affe2edfa0fdd04b3bba5907e00ebb8c80ed2
parent ecb6e36a
...@@ -115,7 +115,8 @@ from Products.ERP5Type.Utils import str2bytes ...@@ -115,7 +115,8 @@ from Products.ERP5Type.Utils import str2bytes
hosed_connection = ( hosed_connection = (
CR.SERVER_GONE_ERROR, CR.SERVER_GONE_ERROR,
CR.SERVER_LOST CR.SERVER_LOST,
CR.COMMANDS_OUT_OF_SYNC
) )
query_syntax_error = ( query_syntax_error = (
...@@ -404,7 +405,12 @@ class DB(TM): ...@@ -404,7 +405,12 @@ class DB(TM):
else: else:
LOG('ZMySQLDA', ERROR, 'query failed: %s' % (query,)) LOG('ZMySQLDA', ERROR, 'query failed: %s' % (query,))
raise raise
except ProgrammingError: except ProgrammingError as m:
if (allow_reconnect or not self._use_TM) and \
m[0] in hosed_connection:
self._forceReconnection()
self.db.query(query)
else:
LOG('ZMySQLDA', ERROR, 'query failed: %s' % (query,)) LOG('ZMySQLDA', ERROR, 'query failed: %s' % (query,))
raise raise
try: try:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment