#34865: DatabaseWrapper are not GC and connections are not closed
-------------------------------------+-------------------------------------
     Reporter:  Fábio Domingues      |                    Owner:  Priyank
                                     |  Panchal
         Type:  Bug                  |                   Status:  assigned
    Component:  Database layer       |                  Version:  4.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  1                    |  Patch needs improvement:  1
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Florian Apolloner):

 Hi Patryk, I agree which is why this ticket is accepted. It just needs a
 PR with tests (or an explanation why tests make no sense, are not
 possible) and then we can see what we can do about that.

 > What makes it worse is that in this case, it holds a reference to a
 `psycopg` connection object, holding all of the psycopg internals hostage
 and preventing proper finalization of the connection (and, I assume, in
 Django 5.x also preventing the connection from being reclaimed by the
 connection pool? I did not verify that).

 I don't think so, the connection is not returned to the pool on GC but
 rather when `.close` is called on it at the end of the request:
 
https://github.com/django/django/blob/5da3ad7bf90fba7321f4c2834db44aa920c70bc7/django/db/backends/postgresql/base.py#L391
-- 
Ticket URL: <https://code.djangoproject.com/ticket/34865#comment:14>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070194d5ffc443-6fb0a624-d837-42aa-a835-05bc866609c0-000000%40eu-central-1.amazonses.com.

Reply via email to