From 891c5306242760c8bb494412b9f8f86762664427 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Thu, 22 Nov 2012 20:55:50 +0100 Subject: [PATCH] Fixed #18984 -- Avoided a deadlock in test teardown. Thanks Jeremy Dunck for the report. --- django/test/testcases.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/django/test/testcases.py b/django/test/testcases.py index 96178b4c86d..0f76e11c1a6 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -505,6 +505,12 @@ class TransactionTestCase(SimpleTestCase): # If the test case has a multi_db=True flag, flush all databases. # Otherwise, just flush default. databases = connections if getattr(self, 'multi_db', False) else [DEFAULT_DB_ALIAS] + + # Roll back any pending transactions in order to avoid a deadlock + # during flush when TEST_MIRROR is used (#18984). + for conn in connections.all(): + conn.rollback_unless_managed() + for db in databases: call_command('flush', verbosity=0, interactive=False, database=db, skip_validation=True, reset_sequences=False)