#18984: TransactionTestCase._fixture_teardown locks under mysql
-----------------------------------+------------------------------------
     Reporter:  jdunck             |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  master
     Severity:  Release blocker    |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  1                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------

Comment (by aaugustin):

 I'm attaching a test case that triggers the deadlock. You need an
 appropriate DATABASES setting — see the comments in the patch.

 Running the test with MySQL deadlocks. It dies after the third Ctrl-C with
 the trace below. This is reproducible.

 {{{
 (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'...
 E^C^C^CE
 ======================================================================
 ERROR: test_teardown_deadlock
 (regressiontests.test_runner.tests.MirrorDeadlockTest)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File
 "/Users/myk/Documents/dev/django/tests/regressiontests/test_runner/tests.py",
 line 298, in test_teardown_deadlock
     Person.objects.using('default').create(first_name='Adrian',
 last_name='Holovaty')
   File "/Users/myk/Documents/dev/django/django/db/transaction.py", line
 202, in __exit__
     self.exiting(exc_value, self.using)
   File "/Users/myk/Documents/dev/django/django/db/transaction.py", line
 287, in exiting
     leave_transaction_management(using=using)
   File "/Users/myk/Documents/dev/django/django/db/transaction.py", line
 51, in leave_transaction_management
     connection.leave_transaction_management()
   File "/Users/myk/Documents/dev/django/django/db/backends/__init__.py",
 line 126, in leave_transaction_management
     "Transaction managed block ended with pending COMMIT/ROLLBACK")
 TransactionManagementError: Transaction managed block ended with pending
 COMMIT/ROLLBACK

 ======================================================================
 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
 510, 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 156.871s

 FAILED (errors=2)
 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.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18984#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to