Opened 15 months ago

Closed 12 months ago

Last modified 12 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

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 15 months ago.
Patch containing a fix
test_broken_pipe.py (395 bytes) - added by garron 15 months ago.
Test that demonstrates issue

Download all attachments as: .zip

Change History (5)

Changed 15 months ago by garron

Patch containing a fix

Changed 15 months ago by garron

Test that demonstrates issue

comment:1 Changed 12 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).

Thanks!

comment:2 Changed 12 months ago by magopian

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

comment:3 Changed 12 months ago by magopian

might be related to #22414 and #22420

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