#19343 closed Bug (fixed)
TransactionTestCase + TEST_MIRROR + multi_db = deadlock
Reported by: | Aymeric Augustin | Owned by: | Aymeric Augustin |
---|---|---|---|
Component: | Testing framework | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
This ticket is split from https://code.djangoproject.com/ticket/18984#comment:5
When TEST_MIRROR
is used, an empty test case within a TransactionTestCase
that declares multi_db = True
deadlocks.
With MySQL, the test runner dies after the third Ctrl-C with the trace below.
(django-dev)myk@mYk tests % PYTHONPATH=.. ./runtests.py --settings=test_mysql_local test_runner.MirrorDeadlockTest ~/Documents/dev/django/tests Creating test database for alias 'default'... Creating test database for alias 'other'... You're going to deadlock, human. MUHAHA. .^C^C^CE ====================================================================== ERROR: test_teardown_deadlock (regressiontests.test_runner.tests.MirrorDeadlockTest) ---------------------------------------------------------------------- Traceback (most recent call last): File "/Users/myk/Documents/dev/django/django/test/testcases.py", line 478, in __call__ self._post_teardown() File "/Users/myk/Documents/dev/django/django/test/testcases.py", line 492, in _post_teardown self._fixture_teardown() File "/Users/myk/Documents/dev/django/django/test/testcases.py", line 517, in _fixture_teardown skip_validation=True, reset_sequences=False) File "/Users/myk/Documents/dev/django/django/core/management/__init__.py", line 160, in call_command return klass.execute(*args, **defaults) File "/Users/myk/Documents/dev/django/django/core/management/base.py", line 252, in execute output = self.handle(*args, **options) File "/Users/myk/Documents/dev/django/django/core/management/base.py", line 382, in handle return self.handle_noargs(**options) File "/Users/myk/Documents/dev/django/django/core/management/commands/flush.py", line 64, in handle_noargs transaction.rollback_unless_managed(using=db) File "/Users/myk/Documents/dev/django/django/db/transaction.py", line 128, in rollback_unless_managed connection.rollback_unless_managed() File "/Users/myk/Documents/dev/django/django/db/backends/__init__.py", line 222, in rollback_unless_managed self._rollback() File "/Users/myk/Documents/dev/django/django/db/backends/mysql/base.py", line 420, in _rollback BaseDatabaseWrapper._rollback(self) File "/Users/myk/Documents/dev/django/django/db/backends/__init__.py", line 58, in _rollback return self.connection.rollback() OperationalError: (2006, 'MySQL server has gone away') ---------------------------------------------------------------------- Ran 1 test in 3.969s FAILED (errors=1) Destroying test database for alias 'default'... Destroying test database for alias 'other'...
Running the test with PostgreSQL also deadlocks, and refuses to die with Ctrl-C, so I don't have a stack trace.
During the deadlock, ps
shows:
postgres: django test_django [local] TRUNCATE TABLE waiting postgres: django test_django [local] idle in transaction
Attachments (1)
Change History (6)
by , 12 years ago
Attachment: | 19343.diff added |
---|
comment:1 by , 12 years ago
Has patch: | set |
---|
comment:2 by , 12 years ago
Owner: | changed from | to
---|
comment:4 by , 12 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
For the same reason as #18984, it isn't really possible to add a test for this.
The fix can be verified manually by adding this test, and checking if a deadlock happens during teardown