[session] try to reconnect on unexpected error in system_sql. We need this for proper reconnection of pool used by hooks or looping task doing sql queries (such as cw_cleanup_transaction)
--- a/server/session.py Wed Mar 31 12:51:35 2010 +0200
+++ b/server/session.py Wed Mar 31 12:53:24 2010 +0200
@@ -278,8 +278,13 @@
"""return a sql cursor on the system database"""
if not sql.split(None, 1)[0].upper() == 'SELECT':
self.mode = 'write'
- return self.pool.source('system').doexec(self, sql, args,
- rollback=rollback_on_failure)
+ source = self.pool.source('system')
+ try:
+ return source.doexec(self, sql, args, rollback=rollback_on_failure)
+ except (source.OperationalError, source.InterfaceError):
+ source.warning("trying to reconnect")
+ self.pool.reconnect(self)
+ return source.doexec(self, sql, args, rollback=rollback_on_failure)
def set_language(self, language):
"""i18n configuration for translation"""