Opened 17 years ago

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

Download all attachments as: .zip

Change History (15)

by John Shaffer <jshaffer2112@…>, 17 years ago

Attachment: models.py added

The test case models file.

by John Shaffer <jshaffer2112@…>, 17 years ago

Attachment: tests.py added

The tests that expose the problem.

comment:1 by John Shaffer <jshaffer2112@…>, 17 years ago

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

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

comment:2 by John Shaffer <jshaffer2112@…>, 17 years ago

A fix for #5043 could affect this.

comment:3 by asderose@…, 16 years ago

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.

by asderose@…, 16 years ago

Patch

comment:4 by anonymous, 16 years ago

Version: 0.96SVN

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

by asderose@…, 16 years ago

Attachment: reconnect.diff added

Corrected formatting of previous patch

comment:5 by Chris Beaven, 16 years ago

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 by Jacob, 16 years ago

Triage Stage: UnreviewedAccepted

by Adriano deRose, 16 years ago

Attachment: psycopg2.patch added

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

comment:7 by Gabriel Hurley, 13 years ago

Severity: Normal
Type: Bug

comment:8 by Aymeric Augustin, 12 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:9 by Aymeric Augustin, 12 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:10 by Anssi Kääriäinen, 12 years ago

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