Opened 8 years ago

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

Download all attachments as: .zip

Change History (15)

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

The test case models file.

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

The tests that expose the problem.

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

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

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

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

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

A fix for #5043 could affect this.

comment:3 Changed 7 years ago by asderose@…

  • Has patch set
  • Needs tests set
  • Version changed from SVN to 0.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 7 years ago by asderose@…

Patch

comment:4 Changed 7 years ago by anonymous

  • Version changed from 0.96 to SVN

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

Changed 7 years ago by asderose@…

Corrected formatting of previous patch

comment:5 Changed 7 years ago by SmileyChris

  • 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 7 years ago by jacob

  • Triage Stage changed from Unreviewed to Accepted

Changed 7 years ago by Adriano

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

comment:7 Changed 4 years ago by gabrielhurley

  • Severity set to Normal
  • Type set to Bug

comment:8 Changed 3 years ago by aaugustin

  • UI/UX unset

Change UI/UX from NULL to False.

comment:9 Changed 3 years ago by aaugustin

  • Easy pickings unset

Change Easy pickings from NULL to False.

comment:10 Changed 3 years ago by akaariai

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

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