[transaction] do not attempt to reconnect if there has been some write during the transaction stable
authorSylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 15 Jul 2010 11:38:31 +0200
branchstable
changeset 5975 5120d97e2f7e
parent 5958 9bfa823735e0
child 5976 00b1b6b906cf
[transaction] do not attempt to reconnect if there has been some write during the transaction
server/sources/native.py
--- a/server/sources/native.py	Mon Jul 12 12:28:19 2010 +0200
+++ b/server/sources/native.py	Thu Jul 15 11:38:31 2010 +0200
@@ -451,13 +451,17 @@
         try:
             cursor = self.doexec(session, sql, args)
         except (self.OperationalError, self.InterfaceError):
+            if session.mode == 'write':
+                # do not attempt to reconnect if there has been some write
+                # during the transaction
+                raise
             # FIXME: better detection of deconnection pb
             self.warning("trying to reconnect")
             session.pool.reconnect(self)
             cursor = self.doexec(session, sql, args)
         except (self.DbapiError,), exc:
             # We get this one with pyodbc and SQL Server when connection was reset
-            if exc.args[0] == '08S01':
+            if exc.args[0] == '08S01' and session.mode != 'write':
                 self.warning("trying to reconnect")
                 session.pool.reconnect(self)
                 cursor = self.doexec(session, sql, args)