diff --git a/django/db/transaction.py b/django/db/transaction.py index 1a3699121f..aae0f3f714 100644 --- a/django/db/transaction.py +++ b/django/db/transaction.py @@ -325,7 +325,13 @@ class Atomic(object): try: connection.savepoint_commit(sid) except DatabaseError: - connection.savepoint_rollback(sid) + try: + connection.savepoint_rollback(sid) + except Error: + # If rolling back to a savepoint fails, mark for + # rollback at a higher level and avoid shadowing + # the original exception. + connection.needs_rollback = True raise else: # Commit transaction @@ -351,7 +357,7 @@ class Atomic(object): else: try: connection.savepoint_rollback(sid) - except DatabaseError: + except Error: # If rolling back to a savepoint fails, mark for # rollback at a higher level and avoid shadowing # the original exception.