From 4f4f1a52af05872120af43a754d06bc4acfba3e6 Mon Sep 17 00:00:00 2001 From: Anthony Brennan Date: Tue, 14 Sep 2021 19:00:18 -0400 Subject: [PATCH] Prevent problem where repos at the 'bottom' of the dictionary were failing to sync during periods of extended load --- merlin/merlin.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/merlin/merlin.py b/merlin/merlin.py index cd6fb06..0099a6e 100755 --- a/merlin/merlin.py +++ b/merlin/merlin.py @@ -1,6 +1,6 @@ #!/usr/bin/python2 -import time, sys, os, errno, logging, signal, copy, select, socket, grp +import time, sys, os, errno, logging, signal, copy, select, socket, grp, random daily = 86400 twice_daily = 86400 / 2 @@ -634,7 +634,10 @@ def await_command(ear): logging.error('Could not communicate with arthur over socket.') def new_jobs(now): - for current in repos: + #To prevent repos at the 'bottom' of the dictionary from getting neglected when mirror is under unusual load (and merlin is running at MAX_JOBS) + keys = repos.keys() + random.shuffle(keys) + for current in keys: if len(jobs) >= MAX_JOBS: break if now <= repos[current]['last-attempt'] + mintime: