Skip to content

Commit

Permalink
Index worker_runs data structure by short_worker_name.
Browse files Browse the repository at this point in the history
If the worker runs out of GitHub api call then the server
consults the worker_runs data structure to send the worker
only runs it has seen before.

However currently this data structure is indexed by uuid
which does not persist across worker restarts. In this PR
we change the index to the worker name, which is persistent.
  • Loading branch information
vdbergh authored and ppigazzini committed Jan 17, 2025
1 parent 620979a commit 0087ae4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions server/fishtest/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@ def sync_request_task(self, worker_info):
near_github_api_limit = worker_info["near_github_api_limit"]

# Now we sort the list of unfinished runs according to priority.
last_run_id = self.worker_runs.get(unique_key, {}).get("last_run", None)
last_run_id = self.worker_runs.get(my_name, {}).get("last_run", None)

def priority(run): # lower is better
return (
Expand Down Expand Up @@ -1191,8 +1191,7 @@ def priority(run): # lower is better
# GitHub API limit...
if near_github_api_limit:
have_binary = (
unique_key in self.worker_runs
and run_id in self.worker_runs[unique_key]
my_name in self.worker_runs and run_id in self.worker_runs[my_name]
)
if not have_binary:
continue
Expand Down Expand Up @@ -1286,10 +1285,10 @@ def priority(run): # lower is better
# the worker has seen, as well as the last id that was seen.
# Note that "worker_runs" is empty after a server restart.
with self.worker_runs_lock:
if unique_key not in self.worker_runs:
self.worker_runs[unique_key] = {}
self.worker_runs[unique_key][run_id] = True
self.worker_runs[unique_key]["last_run"] = run_id
if my_name not in self.worker_runs:
self.worker_runs[my_name] = {}
self.worker_runs[my_name][run_id] = True
self.worker_runs[my_name]["last_run"] = run_id

return {"run": run, "task_id": task_id}

Expand Down
2 changes: 1 addition & 1 deletion server/fishtest/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ def flags_must_match(run):
}

worker_runs_schema = {
uuid: {
short_worker_name: {
run_id: True,
"last_run": run_id,
}
Expand Down

0 comments on commit 0087ae4

Please sign in to comment.