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)
Change History (12)
comment:1 by , 15 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 15 years ago
Keywords: | innodb mysql added |
---|
comment:3 by , 15 years ago
Cc: | added |
---|
comment:4 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:5 by , 14 years ago
Owner: | changed from | to
---|---|
Status: | assigned → new |
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.
comment:7 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Bug |
comment:13 by , 12 years ago
Resolution: | → duplicate |
---|---|
Status: | new → closed |
I think this has been fixed along #16809.
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.