Storm Django layer does not correctly capture disconnection errors when using PostgreSQL backend

Bug #854787 reported by James Henstridge
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Storm
Fix Released
Critical
James Henstridge

Bug Description

The storm.django integration package allows code using the Django ORM to reuse the same database connection that Storm is using. It also tries to make sure those accesses integrate with Storm's database disconnection logic, but this is failing with the PostgreSQL backend.

Storm provides a wrapped cursor that passes all accesses through the _check_disconnect() helper to track problems:

    def _cursor(self, *args):
        cursor = super(StormDatabaseWrapperMixin, self)._cursor(*args)
        self._store._event.emit("register-transaction")
        return StormCursorWrapper(self._store, cursor)

When used with PostgreSQL, this method chains up to django.db.backends.postgresql_psycopg2.base.DatabaseWrapper._cursor, which also happens to wrap the cursor. This cursor wrapper replaces the database errors generated by the cursor with one of IntegrityError or DatabaseError from django.db.utils.

The is_disconnection_error() implementation for Storm's PostgreSQL backend does not check for Django's error objects, and also does not expect disconnections to be raised as plain DatabaseErrors (it expects them to be reported using one of the subclasses, since that is how psycopg2 behaves).

Some how, we need this is_disconnection_error() routine to trigger on these wrapped exceptions.

Related branches

Revision history for this message
James Henstridge (jamesh) wrote :

Actually, it looks like all the Django backend modules provide a similar cursor wrapper. So this probably affects more than just the PostgreSQL backend.

Changed in storm:
assignee: nobody → James Henstridge (jamesh)
importance: Undecided → Critical
milestone: none → 0.19
status: New → In Progress
Revision history for this message
James Henstridge (jamesh) wrote :

Fix merged in r411.

Changed in storm:
status: In Progress → Fix Committed
Barry Warsaw (barry)
Changed in storm:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.