]> arthur.barton.de Git - netdata.git/commitdiff
try to reconnect to MySQL on OperationalError
authorpaulfantom <paulfantom@gmail.com>
Sun, 7 Aug 2016 13:46:08 +0000 (15:46 +0200)
committerpaulfantom <paulfantom@gmail.com>
Sun, 7 Aug 2016 13:46:08 +0000 (15:46 +0200)
python.d/mysql.chart.py

index 5c996d7768d2545308ede774884c8287f6137d0c..aaeba7fc30b0111383f77a04455cd778bbdbbc6e 100644 (file)
@@ -369,11 +369,20 @@ class Service(SimpleService):
             cursor = self.connection.cursor()
             cursor.execute(QUERY)
             raw_data = cursor.fetchall()
+        except MySQLdb.OperationalError as e:
+            self.debug("Reconnecting due to", str(e))
+            self._connect()
+            cursor = self.connection.cursor()
+            cursor.execute(QUERY)
+            raw_data = cursor.fetchall()
+
+
         except Exception as e:
             self.error("cannot execute query.", e)
             self.connection.close()
             self.connection = None
             return None
+
         data = dict(raw_data)
         try:
             data["Thread_cache_misses"] = int(data["Threads_created"] * 10000 / float(data["Connections"]))