Hi,

Pls find patch for RM2292


Changes: While restoring connections after app restart only establish
connection if that
connection was connected previously.


-- 
*Harshal Dhumal*
*Sr. Software Engineer*

EnterpriseDB India: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index e474817..2d2a46c 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -226,6 +226,7 @@ class Connection(BaseConnection):
         res['conn_id'] = self.conn_id
         res['database'] = self.db
         res['async'] = self.async
+        res['wasConnected'] = self.wasConnected
 
         return res
 
@@ -1565,15 +1566,18 @@ WHERE db.oid = {0}""".format(did))
                 self, conn_info['conn_id'], conn_info['database'],
                 True, conn_info['async']
             )
-
-            try:
-                conn.connect(
-                    password=data['password'],
-                    server_types=ServerType.types()
-                )
-            except Exception as e:
-                current_app.logger.exception(e)
-                self.connections.pop(conn_info['conn_id'])
+            # only try to reconnect if connection was connected previously.
+            if conn_info['wasConnected']:
+                try:
+                    conn.connect(
+                        password=data['password'],
+                        server_types=ServerType.types()
+                    )
+                    # This will also update wasConnected flag in connection so
+                    # no need to update the flag manually.
+                except Exception as e:
+                    current_app.logger.exception(e)
+                    self.connections.pop(conn_info['conn_id'])
 
     def release(self, database=None, conn_id=None, did=None):
         if did is not None:
-- 
Sent via pgadmin-hackers mailing list (pgadmin-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers

Reply via email to