From 1bcc8eb0f64831b24c2769e033a10e530c8ed140 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Thu, 10 Apr 2014 21:14:50 +0200 Subject: [PATCH] [1.7.x] Increased robustness of 58161e4e. Refs #22291. Backport of ee837b9a from master --- 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 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.