From 6b38e48ba11ec3d5aa433948d1354a8627c1edba Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Fri, 11 Apr 2014 22:55:07 +0200 Subject: [PATCH] [1.7.x] Fixed #21166 -- Reset errors_occurred flag after commit and rollback. Backport of 3033a71 from master. Conflicts: django/db/backends/__init__.py --- django/db/backends/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py index 4dab0e3e16e..10836f4651c 100644 --- a/django/db/backends/__init__.py +++ b/django/db/backends/__init__.py @@ -170,6 +170,8 @@ class BaseDatabaseWrapper(object): self.validate_no_atomic_block() self._commit() self.set_clean() + # A successful commit means that the database connection works. + self.errors_occurred = False def rollback(self): """ @@ -179,6 +181,8 @@ class BaseDatabaseWrapper(object): self.validate_no_atomic_block() self._rollback() self.set_clean() + # A successful rollback means that the database connection works. + self.errors_occurred = False def close(self): """ @@ -475,6 +479,8 @@ class BaseDatabaseWrapper(object): self.close() return + # If an exception other than DataError or IntegrityError occurred + # since the last commit / rollback, check if the connection works. if self.errors_occurred: if self.is_usable(): self.errors_occurred = False