Bug #14482 | Server crash when subselecting from the same table | ||
---|---|---|---|
Submitted: | 30 Oct 2005 2:28 | Modified: | 30 Nov 2005 17:31 |
Reporter: | Richard Thorne | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S1 (Critical) |
Version: | 5.0.16-BK, 4.1.16-BK | OS: | Linux (Linux) |
Assigned to: | Evgeny Potemkin | CPU Architecture: | Any |
[30 Oct 2005 2:28]
Richard Thorne
[30 Oct 2005 2:29]
Richard Thorne
Hrm, the text formatter evidently didn't like my tabbed query format much.
[30 Oct 2005 10:45]
Valeriy Kravchuk
Thank you for a problem report. I had reformatted your query slightly and now it looks like the following: SELECT COUNT(*) AS incoming FROM fleets f WHERE (f.TargetID, f.TargetBaseID) IN (SELECT ID, BaseID FROM users u WHERE (u.x, u.y) = (SELECT x, y FROM users WHERE ID='Z4N4g-PVR0p-3ZB3P-6h9t8-7x22b-iC9h3-09225-5xY81-ptc2t-ZdN53' AND BaseID='0')) How many rows are there in your tables? Can you upload a dump of your data? Your my.cnf/my.ini files content may be useful too. Please, send the results of EXPLAIN for this SELECT in your system.
[30 Oct 2005 10:46]
Valeriy Kravchuk
Thank you for a problem report. I had reformatted your query slightly and now it looks like the following: SELECT COUNT(*) AS incoming FROM fleets f WHERE (f.TargetID, f.TargetBaseID) IN (SELECT ID, BaseID FROM users u WHERE (u.x, u.y) = (SELECT x, y FROM users WHERE ID='Z4N4g-PVR0p-3ZB3P-6h9t8-7x22b-iC9h3-09225-5xY81-ptc2t-ZdN53' AND BaseID='0')) How many rows are there in your tables? Can you upload a dump of your data? Your my.cnf/my.ini files content may be useful too. Please, send the results of EXPLAIN for this SELECT in your system.
[30 Oct 2005 12:51]
Richard Thorne
Here's a screenshot of the output from EXPLAIN in phpmyadmin (Primarily in screenshot form because it's easier to read): http://www.starsphere.net/Explain.png There are very few rows in my tables, this is only a test setup, 8 rows in the "users" table and 32 rows in the "fleets" table. Here is a data dump of the table data: http://www.starsphere.net/dump.sql Oh, and I made a typo with the "users" schema query, here is the correct one: CREATE TABLE `users` ( `ID` varchar(150) NOT NULL default '', `BaseID` varchar(150) NOT NULL default '0', `x` int(11) unsigned NOT NULL, `y` int(11) unsigned NOT NULL, PRIMARY KEY (`id`,`baseid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
[30 Oct 2005 14:37]
Valeriy Kravchuk
Tables and data to repeat the crash
Attachment: 14482.sql (text/x-delimtext), 10.93 KiB.
[30 Oct 2005 14:45]
Valeriy Kravchuk
Verified using your test case (see the 14482.sql file attached for convenience) on Linux Fedora Core 1 using latest 5.0.16-BK (ChangeSet@1.1957, 2005-10-29 13:11:34+04:00, konstantin@mysql.com) and your query: mysql> SELECT COUNT(*) AS incoming FROM fleets f -> WHERE (f.TargetID, f.TargetBaseID) IN -> (SELECT ID, BaseID FROM users u -> WHERE (u.x, u.y) = -> (SELECT x, y FROM users -> WHERE ID='Z4N4g-PVR0p-3ZB3P-6h9t8-7x22b-iC9h3-09225-5xY81-ptc2t-ZdN53' -> AND BaseID='0')); ERROR 2013 (HY000): Lost connection to MySQL server during query mysql> Number of processes running now: 0 051030 17:38:28 mysqld restarted Also verified with 4.1.16-BK-debug (ChangeSet@1.2450, 2005-10-27 10:20:38-07:00, jimw@mysql.com). The same crash. Nothing in the error log.
[5 Nov 2005 1:46]
Richard Thorne
A very odd occurance, if you change the single quotes around 'Z4N4g-PVR0p-3ZB3P-6h9t8-7x22b-iC9h3-09225-5xY81-ptc2t-ZdN53' and '0' to double quotes, e.g. SELECT COUNT(*) AS incoming FROM fleets f WHERE (f.TargetID, f.TargetBaseID) IN (SELECT ID, BaseID FROM users u WHERE (u.x, u.y) = (SELECT x, y FROM users WHERE ID="Z4N4g-PVR0p-3ZB3P-6h9t8-7x22b-iC9h3-09225-5xY81-ptc2t-ZdN53" AND BaseID="0")) The query works fine. Now, I know the use of double quotes isn't SQL standard (If memory serves the SQL standard says they're supposed to be used to quote reserved-words only, but MySQL seems to allow them for string literals as well), but this is really rather odd. I hope this helps.
[5 Nov 2005 2:18]
Richard Thorne
On further testing, this seems to only work once, then causes the server to crash the second time you run it.
[10 Nov 2005 19:22]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/32155
[17 Nov 2005 17:14]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/internals/32372
[24 Nov 2005 18:53]
Evgeny Potemkin
resolve_const_item() substitutes item which will evaluate to constant with equvalent constant item, basing on the item's result type. In this case subselect was resolved as constant, and resolve_const_item() was substituting it's result's Item_caches to Item_null. Later Item_cache's function was called for Item_null object, which caused server crash. Fixed in 4.1.16, cset 1.2462.10.1
[25 Nov 2005 22:46]
Evgeny Potemkin
Fixed in 5.0.16
[30 Nov 2005 17:31]
Paul DuBois
Noted in 4.1.16, 5.0.16 changelogs.