Skip to content

Rolled back managed transactions before flushing fixtures. #384

Closed
wants to merge 3 commits into from

2 participants

@jdunck
Django member
jdunck commented Sep 18, 2012

No description provided.

@aaugustin aaugustin commented on an outdated diff Nov 20, 2012
django/test/testcases.py
@@ -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()
+
@aaugustin
Django member
aaugustin added a note Nov 20, 2012

You want connections[db] here, otherwise it won't work when multi_db = False.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@aaugustin
Django member

I have proposed a slightly different patch in Trac. I suggest to continue the discussion over there, since the patch is very small and doesn't really need line-by-line commenting.

@aaugustin aaugustin closed this Nov 22, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.