Fix #21202: Prevent swallowing fatal DB errors in atomic blocks #1696

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
1 participant

intgr added some commits Sep 24, 2013

@intgr intgr Make set_autocommit() wrap backend-specific errors
Since _set_autocommit() may send commands to the database, it can also
throw errors, which would otherwise be backend-specific (e.g.
psycopg2.DatabaseError)
d98c327
@intgr intgr Prevent swallowing fatal DB errors in atomic blocks
Previously, fatal errors like administrator connection termination,
backend crash, "database in recovery" would be masked by Atomic. A
subsequent rollback/set_autocommit would raise a new (less descriptive)
error, such as "InterfaceError: connection already closed".

Easiest way to reproduce this with PostgreSQL::

    from django.db import connection
    from django.db.transaction import atomic

    with atomic():
        cur = connection.cursor()
        cur.execute("select pg_terminate_backend(pg_backend_pid())")
        cur.fetchall()
72ea1d4
Contributor

intgr commented Apr 11, 2014

Fixed upstream in 3becac8 and 8176150. Thanks!

intgr closed this Apr 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment