#33497: Database persistent connections do not work with ASGI in 4.0
-------------------------------------+-------------------------------------
     Reporter:  Stenkar              |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  4.0
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  needsinfo
     Keywords:  ASGI; Database       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * cc: Florian Apolloner, Andrew Godwin (added)


Comment:

 Hi Stenkar.

 Would you be able to put together a minimal test-project here, so that
 folks can reproduce quickly.

 This **may** be due to Django 4.0 having per-request contexts for the
 thread sensitivity of `sync_to_async()` — See #32889.
 If so, that's kind-of a good thing, in that too many open resources is
 what you'd expect in async code, and up to now, we've not been hitting
 that, as we've essentially been running serially.

 Immediate thought for a mitigation would be to use a connection pool.

 Equally, can we limit the number of threads in play using
 
[https://github.com/django/asgiref/blob/02fecb6046bb5ec0dbbad00ffcd2043e893fcea5/asgiref/sync.py#L303-L304
 asgiref's `AGSI_THREADS` environment variable]? (But see
 [https://github.com/django/daphne/issues/319#issuecomment-991962381 the
 discussion on the related Daphne issue about whether that's the right
 place for that at all].)

 This is likely a topic we'll need to deal with (eventually) in Django:
 once you start getting async working, you soon hit resource limits, and
 handling that with structures for sequencing and maximum parallelism is
 one of those hard-batteries™ that we maybe should provide. 🤔

-- 
Ticket URL: <https://code.djangoproject.com/ticket/33497#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/064.c7c39b71208515a9d8654343ae156a48%40djangoproject.com.

Reply via email to