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

Workers restart with --max-requests=0 when --max-requests-jitter is set to nonzero value #1978

Closed
joekohlsdorf opened this issue Feb 5, 2019 · 4 comments

Comments

@joekohlsdorf
Copy link

joekohlsdorf commented Feb 5, 2019

To reproduce, start gunicorn like this:

gunicorn -w 1 --max-requests=0 --max-requests-jitter=10 -b 0.0.0.0:8000 api:app

Then direct some traffic to it and observe the following log output:

[2019-02-05 20:27:23 +0000] [19] [INFO] Starting gunicorn 19.9.0
[2019-02-05 20:27:23 +0000] [19] [INFO] Listening at: http://0.0.0.0:8000 (19)
[2019-02-05 20:27:23 +0000] [19] [INFO] Using worker: sync
[2019-02-05 20:27:23 +0000] [22] [INFO] Booting worker with pid: 22
[2019-02-05 20:27:37 +0000] [22] [INFO] Autorestarting worker after current request.
[2019-02-05 20:27:37 +0000] [22] [INFO] Worker exiting (pid: 22)
[2019-02-05 20:27:37 +0000] [24] [INFO] Booting worker with pid: 24

I expect that --max-requests-jitter has no effect when --max-requests is set to 0.

@tilgovi
Copy link
Collaborator

tilgovi commented Feb 6, 2019

What is the behavior you're expecting? Normally, max-requests=0 should mean that workers never auto-restart but from your log it looks as though it does.

@benoitc
Copy link
Owner

benoitc commented Feb 7, 2019

This error has been introduced in d4e1bfe:

The line self.max_requests = cfg.max_requests + jitter or MAXSIZE now self.max_requests = cfg.max_requests + jitter or sys.maxsize since e974f30 will set self.max_requests to the jitter value.

We should really set self.max_requests only if its setting value is greater than 0.

@benoitc benoitc added the bug :( label Feb 7, 2019
@benoitc benoitc added this to the 20.0 milestone Feb 7, 2019
@benoitc benoitc self-assigned this Feb 7, 2019
benoitc added a commit that referenced this issue Feb 7, 2019
benoitc added a commit that referenced this issue Feb 7, 2019
@benoitc
Copy link
Owner

benoitc commented Feb 8, 2019

@joekohlsdorf the patch above should fix the error but let us know...

@joekohlsdorf
Copy link
Author

Thanks, looks good to me.

di pushed a commit to di/gunicorn that referenced this issue Sep 21, 2019
fix benoitc#1978

(cherry picked from commit 7ed20f6)
tilgovi pushed a commit that referenced this issue Oct 13, 2019
fix #1978

(cherry picked from commit 7ed20f6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants