Opened 9 years ago

Closed 4 years ago

#5063 closed Bug (fixed)

PostgreSQL connection close when using model with a OneToOneField and a ManyToManyField

Reported by: John Shaffer <jshaffer2112@…> Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: yes Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

I'm attaching models and tests files that raise unclear errors with r4610 (which is still the case with r5788), but raise straightforward errors with r4609. If you run the test code from within a Python shell, you'll see that at first clear error messages are given, but after a couple of errors the PostgreSQL connection is closed and you get InterfaceError: connection already closed. When run as a doctest, the InterfaceError occurs before the straightforward error message is ever displayed.

This bug report is about the PostgreSQL connection close. This is the simplest models file that I was able to cause the error with.

I'm using psycopg2 2.0.6, PostgreSQL 8.2, Python 2.5, and Windows XP.

Attachments (5)

models.py (393 bytes) - added by John Shaffer <jshaffer2112@…> 9 years ago.
The test case models file.
tests.py (825 bytes) - added by John Shaffer <jshaffer2112@…> 9 years ago.
The tests that expose the problem.
django.db.backends.postgresql_psycopg2.base.patch (328 bytes) - added by asderose@… 9 years ago.
Patch
reconnect.diff (778 bytes) - added by asderose@… 9 years ago.
Corrected formatting of previous patch
psycopg2.patch (713 bytes) - added by Adriano deRose 9 years ago.
Updated version for Django trunk. Note: This requires testing in production

Download all attachments as: .zip

Change History (15)

Changed 9 years ago by John Shaffer <jshaffer2112@…>

Attachment: models.py added

The test case models file.

Changed 9 years ago by John Shaffer <jshaffer2112@…>

Attachment: tests.py added

The tests that expose the problem.

comment:1 Changed 9 years ago by John Shaffer <jshaffer2112@…>

The connection close doesn't occur with the psycopg backend.

Jim Moffitt's patch in #3460 fixes this issue.

comment:2 Changed 9 years ago by John Shaffer <jshaffer2112@…>

A fix for #5043 could affect this.

comment:3 Changed 9 years ago by asderose@…

Has patch: set
Needs tests: set
Version: SVN0.96

This patch resolves the issue without altering isolation level (as #3460 does)

One of the side-effects of #3460 is to disable explicit transaction handling - this patch preserves it.

It's been running in a production environment now for several months without any re-occurence of the error.

Changed 9 years ago by asderose@…

Patch

comment:4 Changed 9 years ago by anonymous

Version: 0.96SVN

Whoops, didn't mean to change the version - my apologies.
The submitted patch however has only been tested with 0.96

Changed 9 years ago by asderose@…

Attachment: reconnect.diff added

Corrected formatting of previous patch

comment:5 Changed 9 years ago by Chris Beaven

Patch needs improvement: set

Thanks for the patch, asderose. If you can, it'd be better to provide the patch against SVN (it's extremely doubtful that this fix would be backported to 0.96).

comment:6 Changed 9 years ago by Jacob

Triage Stage: UnreviewedAccepted

Changed 9 years ago by Adriano deRose

Attachment: psycopg2.patch added

Updated version for Django trunk. Note: This requires testing in production

comment:7 Changed 6 years ago by Gabriel Hurley

Severity: Normal
Type: Bug

comment:8 Changed 5 years ago by Aymeric Augustin

UI/UX: unset

Change UI/UX from NULL to False.

comment:9 Changed 5 years ago by Aymeric Augustin

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:10 Changed 4 years ago by Anssi Kääriäinen

Resolution: fixed
Status: newclosed

I don't believe this to be an issue any longer. We would have heard more of this if this were still an issue...

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