-
Notifications
You must be signed in to change notification settings - Fork 25
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
Wait for ongoing uploads and downloads when shutting down the worker #882
Conversation
I moved it to I propose we register ongoing uploads and downloads and wait for them to finish when shutting down the worker, this means we'll only use the shutdown context to prevent starting new uploads/downloads when we were blocking on memory. I added a middleware to check if the shutdown context was cancelled, and if that is the case we return service unavailable... this way we make sure we only handle ongoing requests and not take on any new ones. I also want to change the way we handle the shutdown timeout, we now divide it by the number of services we have but that seems a little arbitrary. I see how it allows every service to shut down gracefully but at the same time it might needlessly prevent a service from shutting down gracefully simply because we restrict it to Maybe we can allocate (an arbitrary) 5 seconds to every service and reserve that. So we subtract that time from the shutdown timeout and then we just allow all services to use the remaining time, if we do timeout we still have that reserve to ensure we can gracefully shut down the rest. I feel this would give time to those services that need it, while ensuring we're not giving the opportunity to following services to complete their shutdown. |
625c12f
to
f1836b5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you manually tested this a few times to see if it throws any unexpected errors?
41e302b
to
49a9cb3
Compare
I manually tested it a bunch of times. Downloads and uploads are handled gracefully, and we do reserve a portion of the shutdown ctx to try and shut down the remaining services in case we time out. If the worker shut down times out though, we might not record some interactions and then we get:
|
Converting it to |
ae8e4a4
to
3657563
Compare
8dab060
to
1d4edff
Compare
1d4edff
to
5118f70
Compare
This was never scheduled and is not currently a priority. |
This PR makes the worker shut down gracefully and allows ongoing uploads and downloads to finish.