Code

Opened 7 years ago

Closed 4 years ago

#3620 closed (duplicate)

test suite aborts with mysql 4.1

Reported by: mir@… Owned by: nobody
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

With the test fixtures, the test suite aborts (not a regular failure!) with these messages:

Doctest: modeltests.transactions.models.__test__.API_TESTS ... ok
Doctest: modeltests.validation.models.__test__.API_TESTS ... ok
Error: Database django_test_db couldn't be flushed. Possible reasons:
  * The database isn't running or isn't configured correctly.
  * At least one of the expected database tables doesn't exist.
  * The SQL was invalid.
Hint: Look at the output of 'django-admin.py sqlflush'. That's the SQL this command wasn't able to run.
The full error: (1192, "Can't execute the given command because you have active locked tables or an active transaction")

If I go to the commit before the test fixtures, only the json tests fail (because of the forward reference problem).

I use mysql 4.1.11a-4sarge7 from debian with InnoDB storage.

Attachments (1)

ticket-3620.diff (1.1 KB) - added by Michael Radziej <mir@…> 7 years ago.
patch

Download all attachments as: .zip

Change History (9)

comment:1 follow-up: Changed 7 years ago by ubernostrum

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

There's a lively debate on the developers list going on right now about the myriad problems InnoDB tables cause for the test fixtures system.

comment:2 in reply to: ↑ 1 Changed 7 years ago by mir@…

Replying to ubernostrum:

There's a lively debate on the developers list going on right now about the myriad problems InnoDB tables cause for the test fixtures system.

This ticket is not about failing forward references, so it's unrelated.

comment:3 Changed 7 years ago by Michael Radziej <mir@…>

I found the reason for the problem, and it's not within the test framework but in core.management.flush:

Mysql 4.x with InnoDB treats TRUNCATE exactly like a DELETE and needs a COMMIT after it. If the COMMIT is missing and the next statement is another TRUNCATE that removes dependent rows, you get the error message from the ticket description. Take a look at the mysql reference docs.

The appended patch adds a COMMIT after each SQL command. It's been tested with mysql-4.1 and postgresql-8.1.

Changed 7 years ago by Michael Radziej <mir@…>

patch

comment:4 Changed 7 years ago by Michael Radziej <mir@…>

  • Has patch set

comment:5 Changed 7 years ago by Michael Radziej <mir@…>

  • Component changed from Unit test system to django-admin.py

comment:6 Changed 7 years ago by Simon G. <dev@…>

  • Triage Stage changed from Unreviewed to Design decision needed

comment:7 Changed 6 years ago by telenieko

The behaviour of MySQL is standard? I mean, requiring a COMMIT after the TRUNCATE? If not, that would need to be fixed in the mysql backend. Anyway, does this happend with newer mysql's? (I don't have mysql :)

comment:8 Changed 4 years ago by russellm

  • Resolution set to duplicate
  • Status changed from new to closed

Closing as an effective duplicate of #3615. This is a problem because MySQL InnoDB doesn't do referential integrity properly. If we applied the patch proposed here, it would actually break PostgreSQL (and any other database that does referential integrity properly) because you *need* to run all the flush SQL in a single transaction.

#3615 is pending on a way to make MySQL defer constraint checks properly; this ticket needs exactly the same fix in a different way.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.