Skip to content

Commit

Permalink
Some fixes in scavenge_dead_tasks
Browse files Browse the repository at this point in the history
- Remove a race condition

- Do not require a cache entry to be clean before scavenging.

Under heavy load clean cache entries will be a rarity.
  • Loading branch information
vdbergh authored and ppigazzini committed Jun 2, 2024
1 parent ad5e5d4 commit 0e0f1c9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,12 @@ def scavenge_dead_tasks(self):
with self.run_cache_lock:
for cache_entry in self.run_cache.values():
run = cache_entry["run"]
if not cache_entry["is_changed"] and not run["finished"]:
if not run["finished"]:
for task_id, task in enumerate(run["tasks"]):
if (
task["active"]
and task["last_updated"].timestamp() < now - 360
):
cache_entry["is_changed"] = True
dead_tasks.append((task_id, run))
# We release the lock to avoid deadlock
for task_id, run in dead_tasks:
Expand All @@ -541,6 +540,7 @@ def scavenge_dead_tasks(self):
task_id=task_id,
)
self.set_inactive_task(task_id, run)
self.buffer(run, False)

def get_unfinished_runs_id(self):
with self.run_cache_write_lock:
Expand Down

0 comments on commit 0e0f1c9

Please sign in to comment.