#35059: ASGI server leaves stale DB connections
---------------------------------+--------------------------------------
     Reporter:  James Thorniley  |                    Owner:  nobody
         Type:  Bug              |                   Status:  closed
    Component:  Uncategorized    |                  Version:  5.0
     Severity:  Normal           |               Resolution:  needsinfo
     Keywords:                   |             Triage Stage:  Unreviewed
    Has patch:  0                |      Needs documentation:  0
  Needs tests:  0                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+--------------------------------------

Comment (by James Thorniley):

 git bisect found commit 7cd187a5ba58d7769039f487faeb9a5a2ff05540 however I
 think this is a red herring, not sure why it came to that.

 Reverting the changes from 64cea1e48f285ea2162c669208d95188b32bbc82 on top
 of 5.0 fix the problems, so I think that is actually the problematic
 commit.

 This commit moved the `send_response` function into a task which can be
 cancelled if and when `http.disconnect` is received. However the
 `send_response` function was also responsible for calling
 `response.close()` which is a sync function called asynchronously using
 `sync_to_async`. This introduced a race condition as if the
 `http.disconnect` is received during the call to the `sync_to_async`
 wrapped code then the `response.close()` can effectively be cancelled and
 the associated clean up (triggered by the `request_finished` signal from
 inside `response.close()` never gets called.

 If created a PR here for review, it seems to solve the issue for me:
 https://github.com/django/django/pull/17675

-- 
Ticket URL: <https://code.djangoproject.com/ticket/35059#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/0107018cd0202a71-b792220e-5e8a-4320-8d79-33302062e05e-000000%40eu-central-1.amazonses.com.

Reply via email to