Ori.livneh has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/189911

Change subject: Ping server before inserting rows and reconnect if connection 
lost
......................................................................

Ping server before inserting rows and reconnect if connection lost

Whenever a connection is retrieved from the connection pool so that it can be
used to execute an insert, call mysql_ping() to ensure that the connection is
still alive. If it is not, restart it (by passing `True` to conn.ping() -- see
<https://github.com/farcepest/MySQLdb1/blob/master/_mysql.c#L1979-1994>).

Change-Id: I6538f1ec345f4af5b51f5bf4d861e5adec3a19a4
---
M server/eventlogging/handlers.py
1 file changed, 7 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/EventLogging 
refs/changes/11/189911/1

diff --git a/server/eventlogging/handlers.py b/server/eventlogging/handlers.py
index ea3b78b..20e964a 100644
--- a/server/eventlogging/handlers.py
+++ b/server/eventlogging/handlers.py
@@ -97,6 +97,13 @@
                             args=(meta, events, replace))
     worker.start()
 
+    if meta.bind.dialect.name == 'mysql':
+        @sqlalchemy.event.listens_for(sqlalchemy.pool.Pool, 'checkout')
+        def ping(dbapi_connection, connection_record, connection_proxy):
+            # Just before executing an insert, call mysql_ping() to verify
+            # that the connection is alive, and reconnect if necessary.
+            dbapi_connection.ping(True)
+
     try:
         # Link the main thread to the worker thread so we
         # don't keep filling the queue if the worker died.

-- 
To view, visit https://gerrit.wikimedia.org/r/189911
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6538f1ec345f4af5b51f5bf4d861e5adec3a19a4
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/EventLogging
Gerrit-Branch: master
Gerrit-Owner: Ori.livneh <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to