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

Close workers gracefully #2892

Merged
merged 13 commits into from
Jul 31, 2019
Merged

Conversation

mrocklin
Copy link
Member

This allows workers to optionally terminate themselves gracefully after a predetermined time. This can be helpful in a few contexts:

  1. We receive a SIGINT, and know that we need to clean up quickly (though note that the signal handlers are not implemented as part of this PR (cc @jni))
  2. We know that we'll be kicked off at a certain time, such as in one hour from now, as is often specified by HPC job schedulers (cc @lesteve @guillaumeeb @jhamman )
  3. We just want to refresh our workers every once in a while, because we know that our code leaks some memory . Fixes Gracefully restart a worker from a nanny #2861

This is configurable as keywords to the Worker or Nanny classes, in config values, or with CLI. Here is an example with CLI.

Restart to clear state

dask-worker scheduler:8786 --lifetime 1hr --lifetime-restart --lifetime-stagger 5m

This will kill the worker roughly 1 hour from now +- a range of 5 minutes (to avoid killing all of our workers at the same time). It will also allow that worker to be restarted afterwards

Restart to avoid walltime death

dask-worker scheduler:8786 --lifetime 58m 

Here we don't try to restart the worker (no point) and we choose a time a bit before our 60m walltime.

Also cc @jacobtomlinson @jcrist for general deployment information

For folks who want to review. I recommend going commit-by-commit (it should be fairly clean). (this is also a decently simple/educational PR to review)

@mrocklin
Copy link
Member Author

Merging this tomorrow if there are no further comments (Although comments would be quite welcome here)

@TomAugspurger
Copy link
Member

TomAugspurger commented Jul 29, 2019

though note that the signal handlers are not implemented as part of this PR

Do you anticipate this making fixing #2788 easier? Your comment in #2788 (comment) makes it sound like "yes".

Copy link
Member

@TomAugspurger TomAugspurger left a comment

Choose a reason for hiding this comment

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

Implementation looks good at a glance.

@mrocklin
Copy link
Member Author

Do you anticipate this making fixing #2788 easier?

It's the action that I think we would want to take when handling a SIGINT.

@mrocklin
Copy link
Member Author

Merging this shortly if there are no further comments

Copy link
Member

@guillaumeeb guillaumeeb left a comment

Choose a reason for hiding this comment

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

Thanks for this @mrocklin, just a fiew comment on the documentation.

distributed/worker.py Outdated Show resolved Hide resolved
distributed/cli/dask_worker.py Outdated Show resolved Hide resolved
mrocklin and others added 4 commits July 30, 2019 07:02
Co-Authored-By: Guillaume Eynard-Bontemps <g.eynard.bontemps@gmail.com>
Now that we've added --lifetime-restart this is more clear there
@mrocklin mrocklin force-pushed the worker-close-gracefully branch from 87c3082 to 2061fd4 Compare July 30, 2019 22:02
@mrocklin mrocklin force-pushed the worker-close-gracefully branch from e11eaed to 3e7aa67 Compare July 31, 2019 00:20
@mrocklin mrocklin merged commit 5f12043 into dask:master Jul 31, 2019
@mrocklin mrocklin deleted the worker-close-gracefully branch July 31, 2019 14:37
@lesteve
Copy link
Member

lesteve commented Aug 29, 2019

Just a quick comment (I don't think this is a problem for this PR, since the signal handling is only part of it AFAICT): for SGE the signal you get when the job exceed the walltime is a SIGKILL (e.g. kill -9). Not sure for other job schedulers.

@jacobtomlinson
Copy link
Member

Ouch! AFAIK Slurm and PBS send a SIGTERM shortly before the SIGKILL to give the process a chance to exit cleanly.

@lesteve
Copy link
Member

lesteve commented Aug 29, 2019

Good to know that other schedulers are a bit nicer regarding job termination.

I found this which seems to indicate that for SGE SIGKILL is used by default but that you can configure it to be something else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gracefully restart a worker from a nanny
5 participants