-
Notifications
You must be signed in to change notification settings - Fork 92
Closed
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorstaleIndicates issues, pull requests, or discussions are inactiveIndicates issues, pull requests, or discussions are inactive
Description
Bug Report
Description
Connection's connection_id is not updated upon reconnect.
Reproducibility
while loop printing connection id with kill from mysql session
Expected Behavior
connection id should update & match new ID
Additional Research and Context
copying this snippet from constructor into the reconnect logic appears to do the trick; not sure if this is the best place for it however (should perhaps be done in connect_host_hook or Connection.connect, but not sure of other implications) - can PR if is the desired approach:
$ git diff
diff --git a/datajoint/connection.py b/datajoint/connection.py
index 9db3dcb..f2c2f07 100644
--- a/datajoint/connection.py
+++ b/datajoint/connection.py
@@ -305,6 +305,10 @@ class Connection:
raise
warnings.warn("MySQL server has gone away. Reconnecting to the server.")
connect_host_hook(self)
+ if self.is_connected:
+ logger.info("Connected {user}@{host}:{port}".format(**self.conn_info))
+ self.connection_id = self.query('SELECT connection_id()').fetchone()[0]
+
if self._in_transaction:
self.cancel_transaction()
raise errors.LostConnectionError("Connection was lost during a transaction.")
Metadata
Metadata
Assignees
Labels
bugIndicates an unexpected problem or unintended behaviorIndicates an unexpected problem or unintended behaviorstaleIndicates issues, pull requests, or discussions are inactiveIndicates issues, pull requests, or discussions are inactive