Permalink
Browse files

Rolled back managed transactions before flushing fixtures.

  • Loading branch information...
1 parent 319e135 commit 4dbfdc677c6c922f3797be83f67d1a26ab68d221 Jeremy Dunck committed Sep 18, 2012
Showing with 8 additions and 0 deletions.
  1. +8 −0 django/test/testcases.py
View
@@ -557,6 +557,14 @@ def _fixture_teardown(self):
# 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 so that we release locks
+ # for the flushes we're about to do.
+ # (otherwise 2 aliases pointing to the same DB could block each other).
+ # see 18984
+ for db in databases:
+ databases[db].rollback_unless_managed()
+
for db in databases:
call_command('flush', verbosity=0, interactive=False, database=db,
skip_validation=True, reset_sequences=False)

0 comments on commit 4dbfdc6

Please sign in to comment.