To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit aa21a5f0 authored by Reto Da Forno's avatar Reto Da Forno
Browse files

handle MySQLdb connection drops differently in dispatcher

parent a69816ae
......@@ -929,12 +929,13 @@ def stop_test(testid, cur, cn, obsdict_key, obsdict_id, abort=False):
# Set stop time in DB ---
cur.execute("UPDATE `tbl_serv_tests` SET `time_end_act` = UTC_TIMESTAMP() WHERE `serv_tests_key` = %d" %testid)
cn.commit()
return (errors, warnings)
except Exception:
msg = "Unexpected error: %s: %s\n%s" % (str(sys.exc_info()[0]), str(sys.exc_info()[1]), traceback.format_exc())
errors.append(msg)
logger.error(msg)
raise
return (errors, warnings)
### END stop_test()
......@@ -1447,12 +1448,16 @@ def main(argv):
else:
action = "stop"
starttime = time.time()
errors, warnings = stop_test(testid, cur, cn, obsdict_key, obsdict_id, abort)
# Close and reopen the DB connection (if stop test takes longer than usual, the DB connection might get dropped by the server)
try:
errors, warnings = stop_test(testid, cur, cn, obsdict_key, obsdict_id, abort)
except MySQLdb._exceptions.OperationalError:
# if stop test takes longer than usual, the DB connection might get dropped by the server -> reconnect
(cn, cur) = flocklab.connect_to_db()
cur.close()
cn.close()
except:
pass
(cn, cur) = flocklab.connect_to_db()
# Record time needed to set up test for statistics in DB:
time_needed = time.time() - starttime
sql = """ UPDATE `tbl_serv_tests`
......
......@@ -81,8 +81,6 @@ def log_fallback(msg):
def load_config():
global config
if config:
if logger:
logger.debug("Config already loaded")
return SUCCESS
config = get_config()
if not config:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment