#21202: Atomic masks fatal database errors and instead propagates "connection already closed" -------------------------------------+------------------------------------- Reporter: intgr | Owner: aaugustin Type: | Status: assigned Cleanup/optimization | Version: Component: Database layer | 1.6-beta-1 (models, ORM) | Resolution: Severity: Normal | Triage Stage: Accepted Keywords: | Needs documentation: 0 Has patch: 1 | Patch needs improvement: 1 Needs tests: 0 | UI/UX: 0 Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by dji): Whatever happened to this? Seeing this happen a lot on production with 1.6. Even worse, the connection then doesn't get closed, and so all future requests error as well. So should we also be closing the bad connection... somewhere? Longer explanation: As it is with this patch applied (to 1.6, I can't seem to get dev to run), `django.db.close_old_connections()` fails on `conn.rollback()` (which is called by `conn.abort()`) with the same `InterfaceError`. This means that `conn.close_if_unusable_or_obsolete()` never gets called, and the broken connection is reused for later requests, causing all future requests on that connection to error. You can replicate this behavior pretty easily as described above, by enabling connection pooling and terminating your own connection in a request, and then trying to make a subsequent request. I suspect this is still the behavior in dev as well, nothing appears to have changed. My "solution" is to squelch `InterfaceError` as well as `DatabaseError` in `close_old_connections`, but I'm new to the Django internals so I'm not sure if this is best, or if it would be better to just close the connection straight away here in `__exit__` before we return, or what. Happy to help sort this but I'm not sure of the correct approach. -- Ticket URL: <https://code.djangoproject.com/ticket/21202#comment:5> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/063.e6b06a331cdc7cd52b880e4021e788d6%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.