Opened 13 months ago

Closed 10 months ago

Last modified 10 months ago

#22003 closed Bug (worksforme)

LiveServerTestCase with ATOMIC_REQUESTS leaves Postgres connections open after socket error

Reported by: garron Owned by: nobody
Component: Testing framework Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


When using LiveServerTestCase with ATOMIC_REQUESTS, a socket error happening in LiveServerThread can result in Postgres connections being left open. This results in the removal of the test database failing due to those open connections.

I've attached a sample test which exhibits this issue (when using postgres and ATOMIC_REQUESTS). In order for the test to exhibit the issue, there must be a view behind the targeted url.

I've also attached a patch to LiveServerThread that fixes this for me.

Attachments (2)

live_server_testcase.patch (629 bytes) - added by garron 13 months ago.
Patch containing a fix (395 bytes) - added by garron 13 months ago.
Test that demonstrates issue

Download all attachments as: .zip

Change History (5)

Changed 13 months ago by garron

Patch containing a fix

Changed 13 months ago by garron

Test that demonstrates issue

comment:1 Changed 10 months ago by magopian

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

I wasn't able to reproduce this: I ran the test with a postgresql database named test_django configured with ATOMIC_REQUESTS, and a simple return HttpResponse(b"some response") view.

After the test runs (and I do see some Broken pipe error output in the logs), the test database is still removed.

I'm now closing this ticket as works for me, but please reopen it if the ticket is still relevant, with steps to reproduce (and a patch that applies cleanly on the trunk, which isn't the case anymore).


comment:2 Changed 10 months ago by magopian

  • Resolution set to worksforme
  • Status changed from new to closed

comment:3 Changed 10 months ago by magopian

might be related to #22414 and #22420

Note: See TracTickets for help on using tickets.
Back to Top