Skip to content

Commit

Permalink
Use "failed_task" api to flag a stale active task.
Browse files Browse the repository at this point in the history
This is the right thing to do in order to have an audit trail for
tasks that have not played all their games.
  • Loading branch information
vdbergh authored and ppigazzini committed May 22, 2024
1 parent 5e8653a commit fe39141
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,18 +878,16 @@ def priority(run): # lower is better
if unique_key == task_unique_key:
# It seems that this worker was unable to update an old task
# (perhaps because of server issues).
print(
f'Stale active task detected for worker "{my_name_long}". Correcting...',
flush=True,
)
self.set_inactive_task(task_id, run)
# Set the task to inactive and print a message in the event log.
self.failed_task(run["_id"], task_id, message="Stale active task")
continue
last_update = (now - task["last_updated"]).seconds
# 120 = period of heartbeat in worker.
if last_update <= 120:
error = (
f'Request_task: There is already a worker running with name "{task_name_long}" '
f'which sent an update {last_update} seconds ago (my name is "{my_name_long}")'
f'which {last_update} seconds ago sent an update for task {str(run["_id"])}/{task_id} '
f'(my name is "{my_name_long}")'
)
print(error, flush=True)
return {"task_waiting": False, "error": error}
Expand All @@ -900,7 +898,7 @@ def priority(run): # lower is better

connections = 0
connections_limit = self.userdb.get_machine_limit(worker_info["username"])
for run, task_id, task in active_tasks:
for _, _, task in active_tasks:
if task["worker_info"]["remote_addr"] == worker_info["remote_addr"]:
connections += 1
if connections >= connections_limit:
Expand Down

0 comments on commit fe39141

Please sign in to comment.