Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to avoid workers with the same name. #1759

Merged
merged 1 commit into from
Aug 25, 2023

Conversation

vdbergh
Copy link
Contributor

@vdbergh vdbergh commented Aug 24, 2023

During request_task, we check if there are active tasks for workers with the same name, which have recently been updated (i.e. they are not dead). If so then we return an error.

Should fix #1360 (comment) .

@vdbergh vdbergh marked this pull request as draft August 24, 2023 13:57
@vdbergh vdbergh changed the title Try to avoid workers with the same uuid prefix. Try to avoid workers with the same name. Aug 24, 2023
@vdbergh vdbergh marked this pull request as ready for review August 24, 2023 14:06
@vdbergh
Copy link
Contributor Author

vdbergh commented Aug 25, 2023

Hmm CI fails with

======================================================================
ERROR: test_auto_purge_runs (test_api.TestRunFinished.test_auto_purge_runs)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/fishtest/fishtest/server/tests/test_api.py", line 527, in test_auto_purge_runs
    self.assertEqual(response["run"]["_id"], str(run["_id"]))
                     ~~~~~~~~^^^^^^^
KeyError: 'run'

I did not touch autopurge...

@ppigazzini
Copy link
Collaborator

I restarted a couple of times the CI, same error, the raw log doesn't show further information.

@ppigazzini
Copy link
Collaborator

ppigazzini commented Aug 25, 2023

From the error (missing key), it seems that the API request failed.
The PR changes the code of def sync_request_task(self, worker_info): and that function is called over and over in test_api.py.

def test_auto_purge_runs(self):
stop_all_runs(self)
run_id = new_run(self)
run = self.rundb.get_run(run_id)
num_games = 1200
run["args"]["num_games"] = num_games
self.rundb.buffer(run, True)
# Request task 1 of 2
request = self.correct_password_request()
response = ApiView(request).request_task()

@view_config(route_name="api_request_task")
def request_task(self):
self.validate_request("/api/request_task")
worker_info = self.worker_info()
result = self.request.rundb.request_task(worker_info)

def request_task(self, worker_info):
if self.task_semaphore.acquire(False):
try:
with self.task_lock:
return self.sync_request_task(worker_info)

@vdbergh
Copy link
Contributor Author

vdbergh commented Aug 25, 2023

I see. With this PR a worker can no longer have two active tasks at the same time (roughly). I guess this condition will not be satisfied during some tests. I will look at it tonight.

@vdbergh
Copy link
Contributor Author

vdbergh commented Aug 25, 2023

Fixed!

@ppigazzini
Copy link
Collaborator

I will look at it tonight.

I wonder what is your timezone right now..

@vdbergh
Copy link
Contributor Author

vdbergh commented Aug 25, 2023

I couldn't resist to have a quick look and it turned out to be easy to fix (just changing the order of some statements).

@ppigazzini
Copy link
Collaborator

Right now DEV is running with the time aware datetime PR, I will test this PR this evening after loading a clean DB backup.

During request_task, we check if there are active tasks
for workers with the same name, which have recently been
updated (i.e. they are not dead). If so then we return an
error.

Should fix official-stockfish#1360 (comment) .
Copy link
Collaborator

@ppigazzini ppigazzini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good on DEV, tested with a couple of workers started with python3 worker.py --uuid_prefix 123456

@ppigazzini ppigazzini added enhancement server server side changes labels Aug 25, 2023
@ppigazzini ppigazzini merged commit de5eb8e into official-stockfish:master Aug 25, 2023
17 checks passed
@ppigazzini
Copy link
Collaborator

PROD updated, thank you @vdbergh :)

vdbergh added a commit to vdbergh/fishtest that referenced this pull request Aug 29, 2023
ppigazzini pushed a commit that referenced this pull request Aug 29, 2023
vdbergh added a commit to vdbergh/fishtest that referenced this pull request Aug 30, 2023
ppigazzini pushed a commit that referenced this pull request Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement server server side changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Workers with issues.
2 participants