Skip to content

Commit 775c7f3

Browse files
committed
Enable autocommit for markasdone.
This enabled autocommit for the sql queries that updates the XDMoD table that records jobs that have been processed. This is to mitigate a problem observed when a connection times out: the code tries to rerun the queries, but gets a lock wait timout as the first attempt is waint to be committed (and can't becouase the connection has timedout).
1 parent 2683cc7 commit 775c7f3

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/supremm/xdmodaccount.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -302,21 +302,21 @@ def markasdone(self, job, success, elapsedtime, error=None):
302302
data = (job.job_pk_id, version, elapsedtime, version, elapsedtime)
303303

304304
if self.madcon == None:
305-
self.madcon = getdbconnection(self.dbsettings, False)
305+
self.madcon = getdbconnection(self.dbsettings, False, {'autocommit': True})
306306

307307
cur = self.madcon.cursor()
308308

309309
try:
310310
cur.execute(query, data)
311-
except OperationalError:
312-
logging.warning("Lost MySQL Connection. Attempting single reconnect")
313-
self.madcon = getdbconnection(self.dbsettings, False)
311+
except OperationalError as e:
312+
logging.warning("Lost MySQL Connection. " + str(e))
313+
cur.close()
314+
self.madcon.close()
315+
logging.warning("Attempting reconnect")
316+
self.madcon = getdbconnection(self.dbsettings, False, {'autocommit': True})
314317
cur = self.madcon.cursor()
315318
cur.execute(query, data)
316319

317-
self.madcon.commit()
318-
319-
320320
class XDMoDArchiveCache(ArchiveCache):
321321
""" Helper class that adds job accounting records to the database """
322322

0 commit comments

Comments
 (0)