mirror of
				https://github.com/django/django.git
				synced 2025-10-31 09:41:08 +00:00 
			
		
		
		
	Fixed #18984 -- Avoided a deadlock in test teardown.
Thanks Jeremy Dunck for the report.
This commit is contained in:
		| @@ -505,6 +505,12 @@ class TransactionTestCase(SimpleTestCase): | |||||||
|         # If the test case has a multi_db=True flag, flush all databases. |         # If the test case has a multi_db=True flag, flush all databases. | ||||||
|         # Otherwise, just flush default. |         # Otherwise, just flush default. | ||||||
|         databases = connections if getattr(self, 'multi_db', False) else [DEFAULT_DB_ALIAS] |         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: |         for db in databases: | ||||||
|             call_command('flush', verbosity=0, interactive=False, database=db, |             call_command('flush', verbosity=0, interactive=False, database=db, | ||||||
|                          skip_validation=True, reset_sequences=False) |                          skip_validation=True, reset_sequences=False) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user