#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):

 If I understand correctly, this only happens with
 `django.test.TransactionTestCase` and when `multi_db = True` (with
 `django.test.TestCase` tests are wrapped in a transaction that is rolled
 back at the end of the test).

 To reproduce the bug, one should:
 - create two aliases pointing to the same database;
 - create a multi-db transaction test case;
 - with each connection, open a transaction and makes a write (actually, if
 I check the order of connection, I can only do this on the second one).

 Then `_fixture_teardown` will attempt to flush that table using the first
 connection, triggering a lock on the write with the second connection.

 ----

 The more general problem is "should Django's test runner protect users
 against tests that leave pending transactions?". Your answer is "yes".

 The alternative would be to document that transaction test cases must not
 leave pending transactions behind themselves. That would mean putting try
 / finally clauses everywhere -- not nice. Since the fix is quite simple I
 agree with you.

 ----

 I considered adding a test that triggers the bug to the test suite. If
 Django had a regression, the test runner would then hang in teardown,
 without any hint as to what's happening. That doesn't sound useful.
 Therefore, I think this falls under "the test runner can't test itself."

 If you can confirm that I understood the problem correctly, I will
 reproduce it manually and commit your fix.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/18984#comment:4>
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