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

Requests in flight dropped during "graceful" shutdown #2529

Closed
amcinnes opened this issue Feb 26, 2021 · 4 comments
Closed

Requests in flight dropped during "graceful" shutdown #2529

amcinnes opened this issue Feb 26, 2021 · 4 comments
Assignees

Comments

@amcinnes
Copy link

amcinnes commented Feb 26, 2021

gunicorn version: 20.0.4

Expected behaviour: after receiving SIGTERM, gunicorn should not accept any new connections, but should finish handling requests on existing connections (and respond with Connection: close so the client knows not to send another request)

Actual behaviour: In some situations, during a graceful shutdown gunicorn terminates a connection where a request has already been received, without processing the request.

To reproduce:

  1. Put this in app.py (it's an example copied from the docs, but with time.sleep(10) added to it):
import time

def app(environ, start_response):
    """Simplest possible application object"""
    data = b'Hello, World!\n'
    status = '200 OK'
    response_headers = [
        ('Content-type', 'text/plain'),
        ('Content-Length', str(len(data)))
    ]
    time.sleep(10)
    start_response(status, response_headers)
    return iter([data])
  1. Run gunicorn app:app

  2. In two other terminals, run curl localhost:8000

  3. Before the curl commands have finished, send SIGTERM to the master gunicorn process

You will see that one of the curl commands succeeds, and the other one gives an error "Connection reset by peer".

@benoitc
Copy link
Owner

benoitc commented Feb 26, 2021 via email

@amcinnes
Copy link
Author

On Linux.

@tilgovi tilgovi self-assigned this Mar 8, 2021
@tilgovi
Copy link
Collaborator

tilgovi commented Mar 8, 2021

Tracking this over in #1236. If you're using the threaded worker or the eventlet worker, this is a known issue. If not, can you please let us know what worker class you're using and we can keep this open to track that?

@benoitc
Copy link
Owner

benoitc commented Oct 14, 2022

old issue without any activity. closing it. feel free to open a new ticket if needed.

@benoitc benoitc closed this as not planned Won't fix, can't repro, duplicate, stale Oct 14, 2022
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

No branches or pull requests

3 participants