From ee837b9a22220d08fea1e499bec3b094851a1bbe Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Thu, 10 Apr 2014 21:14:50 +0200 Subject: [PATCH] Increased robustness of 58161e4e. Refs #22291. --- django/db/transaction.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/django/db/transaction.py b/django/db/transaction.py index 1f64a689bd..02859a2966 100644 --- a/django/db/transaction.py +++ b/django/db/transaction.py @@ -217,7 +217,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 @@ -243,7 +249,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.