diff --git a/django/test/testcases.py b/django/test/testcases.py
index 96178b4..0f76e11 100644
a
|
b
|
class TransactionTestCase(SimpleTestCase):
|
505 | 505 | # If the test case has a multi_db=True flag, flush all databases. |
506 | 506 | # Otherwise, just flush default. |
507 | 507 | databases = connections if getattr(self, 'multi_db', False) else [DEFAULT_DB_ALIAS] |
| 508 | |
| 509 | # Roll back any pending transactions in order to avoid a deadlock |
| 510 | # during flush when TEST_MIRROR is used (#18984). |
| 511 | for conn in connections.all(): |
| 512 | conn.rollback_unless_managed() |
| 513 | |
508 | 514 | for db in databases: |
509 | 515 | call_command('flush', verbosity=0, interactive=False, database=db, |
510 | 516 | skip_validation=True, reset_sequences=False) |