Opened 15 years ago

Closed 12 years ago

#13533 closed Bug (duplicate)

queries test fails under MySQL InnoDB

Reported by: Russell Keith-Magee Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2-beta
Severity: Normal Keywords: innodb mysql
Cc: Sasha Romijn Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

As of 1.2RC1, the queries test fails under MySQL InnoDB fails at the following test:

Failed example:
    Tag.objects.exclude(children=None)
Expected:
    [<Tag: t1>, <Tag: t3>]
Got:
    [<Tag: t1>, <Tag: t3>, <Tag: t4>]

This is at line 1150 (as of r13252).

This test passes as is under SQLite, Postgres, and MySQL MyISAM.

Even more weird - if you dig into the database at the time the test runs, the query is the same, and the contents of the table is the same. The issue appears to be entirely related to a query cache somewhere in the MySQLdb infrastructure, but only under InnoDB.

You can make the test pass by inserting:

>>> connection.close()

just before the failing test. You can also make the test pass by manually issuing the same query twice, and only checking the test result on the second execution -- i.e., if you modify the test to the following:

>>> r = list(Tag.objects.exclude(children=None))
>>> Tag.objects.exclude(children=None)
[<Tag: t1>, <Tag: t3>]

The test will pass.

Attachments (1)

t13533-tcpdump (13.2 KB ) - added by Sasha Romijn 15 years ago.
tcpdump of communications with mysql

Download all attachments as: .zip

Change History (12)

comment:1 by Russell Keith-Magee, 15 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Sasha Romijn, 15 years ago

Keywords: innodb mysql added

As of r13252? As far as I can see, this was introduced in r12970.

I've played around with transaction isolation levels and query caching, but didn't get any results.

comment:3 by Sasha Romijn, 15 years ago

Cc: Sasha Romijn added

comment:4 by Sasha Romijn, 15 years ago

Owner: changed from nobody to Sasha Romijn
Status: newassigned

comment:5 by Sasha Romijn, 15 years ago

Owner: changed from Sasha Romijn to nobody
Status: assignednew

This would appear to be a MySQL bug, triggered by the testcases.

This problem is triggered by the creation of the ExtraInfo in test_evaluated_queryset_as_argument(), introduced in r12970. Somehow, after that has been done, the same MySQL query yields different results on it's first run, then on subsequent runs.

The query run for the test is:

SELECT `queries_tag`.`id`, `queries_tag`.`name`, `queries_tag`.`parent_id`, `queries_tag`.`category_id` FROM `queries_tag` WHERE NOT
 ((`queries_tag`.`id` IN (SELECT U0.`id` FROM `queries_tag` U0 LEFT OUTER JOIN `queries_tag` U1 ON (U0.`id` = U1.`parent_id`)
WHERE U1.`id` IS NULL) AND NOT (`queries_tag`.`id` IS NULL))) ORDER BY `queries_tag`.`name` ASC LIMIT 21

I have verified this with tcpdump, and MySQL indeed sends back t1, t3 and t4 on the first run, and only t1 and t3 on the second run.
I will attach a log of this.

The insert query for the ExtraInfo looks completely normal:

INSERT INTO `queries_extrainfo` (`info`, `note_id`) VALUES ('good', 1)

Unfortunately a run of the queries suite does over 2000 queries, so it is rather difficult to isolate the problem.
Perhaps someone more experienced can get more out of this.

by Sasha Romijn, 15 years ago

Attachment: t13533-tcpdump added

tcpdump of communications with mysql

comment:6 by Russell Keith-Magee, 14 years ago

The workaround was added to the test case in r15238.

comment:7 by Julien Phalip, 14 years ago

Severity: Normal
Type: Bug

comment:8 by Jacob, 13 years ago

milestone: 1.3

Milestone 1.3 deleted

comment:11 by Aymeric Augustin, 13 years ago

UI/UX: unset

Change UI/UX from NULL to False.

comment:12 by Aymeric Augustin, 13 years ago

Easy pickings: unset

Change Easy pickings from NULL to False.

comment:13 by Claude Paroz, 12 years ago

Resolution: duplicate
Status: newclosed

I think this has been fixed along #16809.

Note: See TracTickets for help on using tickets.
Back to Top