Closed
Description
It seems there have been already several reports related to [CRITICAL] WORKER TIMEOUT
error but it just keeps popping up. Here is my issue.
I'm running this Flask hello world application.
from flask import Flask
application = Flask(__name__)
@application.route('/')
def hello_world():
return 'Hello, World!'
The gunicorn command is this one:
gunicorn -b 0.0.0.0:5000 --log-level=debug hello
And this is the console output:
[2018-06-05 14:56:21 +0200] [11229] [INFO] Starting gunicorn 19.8.1
[2018-06-05 14:56:21 +0200] [11229] [DEBUG] Arbiter booted
[2018-06-05 14:56:21 +0200] [11229] [INFO] Listening at: http://0.0.0.0:5000 (11229)
[2018-06-05 14:56:21 +0200] [11229] [INFO] Using worker: sync
[2018-06-05 14:56:21 +0200] [11232] [INFO] Booting worker with pid: 11232
[2018-06-05 14:56:21 +0200] [11229] [DEBUG] 1 workers
[2018-06-05 14:56:32 +0200] [11232] [DEBUG] GET /
[2018-06-05 14:56:57 +0200] [11232] [DEBUG] Closing connection.
[2018-06-05 14:57:16 +0200] [11232] [DEBUG] GET /
[2018-06-05 14:57:47 +0200] [11229] [CRITICAL] WORKER TIMEOUT (pid:11232)
[2018-06-05 14:57:47 +0200] [11232] [INFO] Worker exiting (pid: 11232)
[2018-06-05 14:57:47 +0200] [11324] [INFO] Booting worker with pid: 11324
Can you please clearly explain why do I get the error and if it's expected in this example? How do I fix it or if it's an expected behavior why critical error then?
Metadata
Metadata
Assignees
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
tilgovi commentedon Jun 5, 2018
The error is not expected, but there is nothing from your example that shows why it happens. Tell us more about your environment.
bigunyak commentedon Jun 6, 2018
=> I just send request from Chromium: http://localhost:5000/
=> No proxy, just Gunicorn + Flask
I've just reproduced the problem on a completely fresh setup, here are the steps:
mkdir gunicorn cd gunicorn/ pipenv --python 3.6 pipenv install flask pipenv install gunicorn vim hello.py pipenv shell gunicorn -b 0.0.0.0:5000 --log-level=debug hello
The
hello.py
is exactly the same Flask application as I posted in the initial report.Below is the complete log.
yunstanford commentedon Jun 8, 2018
@bigunyak I think it's because of the default timeout, your worker has been silent for 30s. http://docs.gunicorn.org/en/stable/settings.html#timeout
From your log,
yunstanford commentedon Jun 8, 2018
I'm seeing the same thing: workers are timing out even when serving no requests, with sync worker.
To that sense, the critical level log is quite confusing.
Try use Gevent worker could solve this.
bigunyak commentedon Jun 8, 2018
Exactly, that was my original question: if it's an expected behavior why critical error then?
Would be also nice to get some background on why workers need to be restarted, maybe this could be added to the Design document.
berkerpeksag commentedon Jun 8, 2018
I'm seeing this as well (reproduced by using
examples/test.py
withgunicorn test:app -b localhost:9595 --log-level=debug --timeout=5
) and I agree that the critical level is a bit confusing. I'd be OK change it to debug level. @benoitc @tilgovi what do you think?yunstanford commentedon Jun 9, 2018
I'm thinking info level might be a little bit better.
neocolor commentedon Jun 14, 2018
I had the same with MSYS2 on Win10 but finally could solved.
in notify() of ...\gunicorn\workers\workertmp.py, os.fchmod is used originally. But it does not work in MSYS. Instead of os.fchmod, I used os.utime. The code is followed. I think it could work for all platform.
benoitc commentedon Jun 20, 2018
@berkerpeksag I wouldn't expect that the worker exit because no requests happen. This error should only happen if the worker has been kept busy for a time > to the timeout. So the error is critical. Imo we should improve the documentation to provide more use cases and responses to such errors.
If the error still happen when the worker is not kept busy then there is something else happening and we have probably a bug.
kozlek commentedon Jul 6, 2018
[EDIT]
Same bug for me.
With Django 1.10 / gunicorn 19.6.0 / Python 2.7.15 in python2.7-alpine on Debian 8.8 and stock kernel 3.16, all was working fine.
After updating to Django 1.11 and gunicorn 19.8.1, the workers keep failing at boot with [CRITICAL WORKER TIMEOUT].
Downgrading gunicorn to 19.6.0 doesn't fix the problem.
We updated the host kernel to 4.9.0 (it was scheduled), and the workers successfully booted without errors.
But:
We're going to try gunicorn gevent to see if we'are able to get our app back online.
kozlek commentedon Jul 6, 2018
Using gunicorn with gevent didn't fixed the bug.
baeriswyld commentedon Aug 2, 2018
any update on this issue ?
92 remaining items