Opened 11 years ago

Closed 10 years ago

Last modified 10 years ago

#22003 closed Bug (worksforme)

LiveServerTestCase with ATOMIC_REQUESTS leaves Postgres connections open after socket error

Reported by: Garron Moore 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

Description

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 Moore 11 years ago.
Patch containing a fix
test_broken_pipe.py (395 bytes ) - added by Garron Moore 11 years ago.
Test that demonstrates issue

Download all attachments as: .zip

Change History (5)

by Garron Moore, 11 years ago

Attachment: live_server_testcase.patch added

Patch containing a fix

by Garron Moore, 11 years ago

Attachment: test_broken_pipe.py added

Test that demonstrates issue

comment:1 by Mathieu Agopian, 10 years ago

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).

Thanks!

comment:2 by Mathieu Agopian, 10 years ago

Resolution: worksforme
Status: newclosed

comment:3 by Mathieu Agopian, 10 years ago

might be related to #22414 and #22420

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