Bug #37439 | Incorrect output order from ORDER BY using 2 field index in MEMORY BTREE | ||
---|---|---|---|
Submitted: | 17 Jun 2008 2:00 | Modified: | 18 Jul 2008 16:10 |
Reporter: | John Nagle | Email Updates: | |
Status: | Can't repeat | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 5.0.27-community-nt | OS: | Windows |
Assigned to: | CPU Architecture: | Any | |
Tags: | enum, order |
[17 Jun 2008 2:00]
John Nagle
[17 Jun 2008 3:23]
Valeriy Kravchuk
Thank you for a problem report. Please, try to repeat with a newer version, 5.0.51, and inform about the results.
[17 Jun 2008 4:06]
John Nagle
I've been able to reproduce the problem on MySQL "5.0.27" running on Red Hat Linux Fedora Core 5. This is a standard server configuration running in a server farm. The original bug was observed on "5.0.27-community-nt" on Windows 2000 running as a desktop system. So it's a cross-platform problem.
[18 Jun 2008 16:55]
John Nagle
Someone else was unable to reproduce the bug. I've been running with ALTER DATABASE testdb DEFAULT CHARACTER SET utf8; to force all text fields to UTF8, but I didn't mention that in the bug report. That changes record size, and might be significant. I'm asking some other MySQL users I know to run tests to try to reproduce this. (It may have been causing problems in our production system. Tests with small tables work fine, but we'd been seeing problems under heavy load. This MEMORY table is a work queue for a busy system, and returning records out of order can stall out the work queue. I can now force the error repeatedly on a desktop system, so we'll get it eventually.)
[18 Jun 2008 19:18]
John Nagle
Reproduced at another site on MySQL 5.0.45 on Linux 2.6.23.15-80.fc7, with this change to make sure that the main text field is UTF8. (The original bug report didn't have that, but the database and server were set up for default UTF8.) So we're accumulating info that this is cross-platform and cross-version. CREATE TABLE ratingqueue ( domain VARCHAR(255) CHARACTER SET utf8 NOT NULL UNIQUE PRIMARY KEY, requestor_ip_hash INT, rating_state ENUM ('running','starting','queued','hold') NOT NULL DEFAULT 'queued', server VARCHAR(63) NULL, priority SMALLINT DEFAULT 0, update_timestamp TIMESTAMP NOT NULL, request_timestamp TIMESTAMP NOT NULL, INDEX(requestor_ip_hash), INDEX USING BTREE(rating_state, request_timestamp) ) ENGINE=MEMORY;
[22 Jun 2008 17:26]
John Nagle
We've been able to demonstrate this defect on three different operating systems (Windows 2000, Linux Fedora Core 5 and Linux Fedora Core 7) and two different versions of MySQL (5.0.27 and 5.0.45). However, it's hard to reproduce; the number of rows matters, and some other attempts to reproduce it (on FreeBSD, for example) have failed. To work on the problem, it's necessary to find a system for which it FAILS and work from there. It's easy to find systems on which the test case appears to work, but that doesn't mean the problem is solved. Debugging on a system on which the test does not fail is useless. It's failing on widely-deployed mainstream configurations, so there are probably operational systems out there getting wrong results from MySQL, but not noticing.
[17 Jul 2008 19:13]
Valeriy Kravchuk
Had you been able to repeat this on any machine with 5.0.51 or newer version?
[18 Jul 2008 2:48]
John Nagle
> Had you been able to repeat this on any machine with 5.0.51 or newer version? It's broken on MySQL as late as 5.0.45. What specific fix between 5.0.45 and 5.0.51 would have fixed the problem? Bear in mind that it's hard to get this to fail; it's sensitive to factors which include, at least, the number of records in the table, as documented above. But since we've seen it has failed on at least three rather different systems, it's real. We suggest you try to reproduce it on 5.0.45 and get a solid, repeatable failure to analyze. Thanks.
[18 Jul 2008 12:18]
Susanne Ebrecht
Many thanks for reporting a bug. I can't repeat this by using newest version of MySQL. Please also read: http://dev.mysql.com/doc/refman/5.0/en/enum.html
[18 Jul 2008 16:10]
John Nagle
It's difficult to repeat this bug and it may not fail on some MySQL configurations, although it's failed on three different systems and versions so far. That's enough to establish that it's real. We'll give the bug more publicity and ask others to try to repeat it. Status: vendor in denial.