#22420: Postgresql connections not being dropped between tests?
-----------------------------------+--------------------------------------
     Reporter:  bacongobbler       |                    Owner:  nobody
         Type:  Bug                |                   Status:  closed
    Component:  Testing framework  |                  Version:  1.6
     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 pwmarcz):

 I'm running about the same problem; it happens after a successful test run
 as well. More details: we're using Django 1.6 (though it happened in 1.5
 as well) and Selenium tests with a `TransactionTestCase` and a
 `LiveServerThread` from Django. After every Selenium test run (in
 `fixture_teardown`) we're closing Selenium then joining the server thread,

 From what I could determine, `django.db.connections.all()` doesn't show
 any other connections after closing the thread; however `SELECT * from
 pg_stat_activity` sometimes reveals a second connection (reported as
 having done `COMMIT;` just before the fixture teardown). The second
 connection often lingers for half a minute. We're not using the
 `CONN_MAX_AGE` setting.

 I should also mention that we're sometimes closing the test while the
 server is processing a request, this is sometimes unavoidable because of
 Ajax requests in a page. Some of these requests get dropped when we close
 Selenium, disconnecting the client. I suspect that the `LiveServerThread`
 (or rather, StoppableWSGIServer) sometimes does not shut down the database
 correctly; maybe when it happens during a long-running request handler.

 For now, we're [[http://stackoverflow.com/questions/5408156/how-to-drop-a
 -postgresql-database-if-there-are-active-connections-to-it|forcibly
 closing all other Postgres connections]] to work around the issue, but
 it'd be great if someone could investigate this.

--
Ticket URL: <https://code.djangoproject.com/ticket/22420#comment:18>
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 post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/070.f18c0180b4e6555b260c5883ef26aae2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to