Bug #40954 | Crash in MyISAM index code with concurrency test using partitioned tables | ||
---|---|---|---|
Submitted: | 23 Nov 2008 10:33 | Modified: | 10 Dec 2008 22:30 |
Reporter: | Guilhem Bichot | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Partitions | Severity: | S3 (Non-critical) |
Version: | 5.1.29, 5.1.30 | OS: | Linux |
Assigned to: | Mattias Jonsson | CPU Architecture: | Any |
[23 Nov 2008 10:33]
Guilhem Bichot
[23 Nov 2008 10:38]
Guilhem Bichot
Probably a recently introduced bug: the previous merge of 5.1main into 5.1maria was revision: 2736 Georgi Kodinov 2008-09-10 [merge] revision-id:kgeorge@mysql.com-20080910095538-o1vuju66760i73up merged 5.0-bugteam to 5.1-bugteam
[24 Nov 2008 14:28]
Mattias Jonsson
This was probably introduced when back porting the read_range implementation in partitioning (bug#37721). This seems to fix it: === modified file 'sql/ha_partition.cc' --- sql/ha_partition.cc 2008-11-10 20:13:24 +0000 +++ sql/ha_partition.cc 2008-11-24 14:25:33 +0000 @@ -4490,7 +4490,8 @@ This can only read record to table->record[0], as it was set when the table was being opened. We have to memcpy data ourselves. */ - error= file->read_range_first(&m_start_key, end_range, eq_range, TRUE); + error= file->read_range_first(m_start_key.key? &m_start_key: NULL, + end_range, eq_range, TRUE); memcpy(rec_buf_ptr, table->record[0], m_rec_length); reverse_order= FALSE; break; I will try to find a simpler test case.
[24 Nov 2008 16:24]
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/commits/59696 2708 Mattias Jonsson 2008-11-24 Bug#40954: Crash in MyISAM index code with concurrency test using partitioned tables Problem was usage of read_range_first with an empty key. Solution was to not to give a key if it was empty.
[24 Nov 2008 18:19]
Mattias Jonsson
The back port was not done in bug#37721, it was done for solving bug#30573/bug33555, and was a backport of the patch for bug#33257.
[24 Nov 2008 20:59]
Omer Barnir
Did some more testing on the above (all the following done with RQG and the above yy and zz files): - No crashes with 5.1.28, crashes with 5.1.29 - Limiting the scenarios to selects that only have pk in the where clause - still crashes - Limiting the scenarios to selects that only have pk with non-zero values clause - still crashes - If the where clause includes a different value that is not the pk - no crash - If no partitions - no crash - If the partitions are not based on the auto_increment pk - no crash
[24 Nov 2008 21:13]
Mikael Ronström
The bug was that in implementing read_range_first in the partition handler the partition handler used two calls to read_range_first, one for ordered scans and one for unordered scans. The unordered scan was correctly implemented and the ordered scan incorrectly. The incorrection was that the use of no start key is a NULL start key and not start_key->key == NULL as was done in this call. Thus the storage engine API was broken in that call. I see no particular risk involved in fixing it.
[24 Nov 2008 21:25]
Omer Barnir
If partitioned are based on the pk that is not auto incremented - still crash
[24 Nov 2008 22:34]
Mattias Jonsson
The bug affects the following statements for partitioned tables: SELECT * FROM part_table WHERE a < const ORDER BY a SELECT * FROM part_table WHERE const < a ORDER BY a desc Where 'a' is an indexed column (does not need to be in the partitioning expression). It must be an 'open' range and ordered index scan where it starts on the 'open' side. It does not depend on partitioning type or expression. The code that include the bug has been in 6.0 since 6.0.5 (see bug#33257) and was backported to 5.1.29 (for bug#30573 / bug#33555).
[24 Nov 2008 23:36]
Mattias Jonsson
pushed into mysql-5.1-bugteam and mysql-6.0-bugteam
[25 Nov 2008 2:11]
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/commits/59746 2778 Build Team 2008-11-25 mysql-test/r/partition.result mysql-test/t/partition.test sql/ha_partition.cc Bug#40954: Crash in MyISAM index code with concurrency test using partitioned tables Problem was usage of read_range_first with an empty key. Solution was to not to give a key if it was empty. (real author Mattias Jonsson) storage/archive/archive_reader.c client/mysqlslap.c Aligned the copyright texts output from "--version" of tools, to let internal tools be able to change them if needed. storage/ndb/test/tools/connect.cpp storage/ndb/test/run-test/atrt.hpp Corrected a few GPL headers not restricted to GPL version 2 Makefile.am Added missing --report-features to the 'test-bt-fast' target support-files/mysql.spec.sh Reversed the removal of the "%define license GPL" in as internal tools depended on it
[25 Nov 2008 2:25]
Trudy Pelzer
SysQA testing of this bug reveals that the use case is more limited than first indicated; some of the difference may be that there are differences between 5.1.30 and the 5.1-main tree. Thus, though this is a regression introduced in 5.1.29, it is also a low-impact issue. Due to the extreme time-criticalness of 5.1.30, I don't believe we have the time to *safely* patch 5.1.30/retest/rebuild and still release by our due date. My decision (with which Jeffrey agrees) is that this is therefore not a showstopper for 5.1.30. Changing tag from 'trg_rfg' to 'sr51mru' but also setting as showstopper for 5.1.31.
[25 Nov 2008 19:29]
Omer Barnir
SysQA tests on 5.1.30 show the following: - The crash is limited to queries like these: SELECT * FROM part_table WHERE a < const ORDER BY a and SELECT * FROM part_table WHERE a <> const ORDER BY a That is, crash happens only if the WHERE clause references an indexed column that is also the partition key, includes a value found in the partition and uses the < or <> operators, and if that same column is used in the ORDER BY clause with an ASC sort priority. *** If the where clause includes a value not found in the primary key, there is no crash. *** If the table is not partitioned, there is no crash. *** If there is no ORDER BY, there is no crash. *** If the ORDER BY sorts only by columns not referred to in the WHERE clause, there is no crash. *** If the operator in the WHERE clause is = or >, there is no crash. *** If the WHERE clause uses < or <> and ORDER BY is DESC, there is no crash A workarownd for the above crashes with < and <> is to add an "AND X > [some small value]" to the qeury as in: SELECT * FROM part_table WHERE a < const AND a > -1000 ORDER BY a or SELECT * FROM part_table WHERE a <> AND a > -1000 ORDER BY a
[26 Nov 2008 12:28]
Bugs System
Pushed into 5.1.30-ndb-6.2.17 (revid:bteam@astra04-20081125020458-m0us9vykrs08b9xm) (version source revid:tomas.ulin@sun.com-20081126122600-j192inmjrcoq1s2i) (pib:5)
[26 Nov 2008 12:59]
Bugs System
Pushed into 5.1.30-ndb-6.3.20 (revid:bteam@astra04-20081125020458-m0us9vykrs08b9xm) (version source revid:tomas.ulin@sun.com-20081126125617-qdxm40iw9if7u559) (pib:5)
[26 Nov 2008 14:51]
Jon Stephens
Documented in the NDB 6.2.17 and NDB 6.3.20 changelogs as follows: ----- A query on a partitioned table caused MySQL to crash, where the query had the following characteristics: · The query's WHERE clause referenced an indexed column that was also in the partitioning key. · The query's WHERE clause included a value found in the partition. · The query's WHERE clause used the < or <> operators to make a comparison with the indexed column's value. · The same indexed column was used in the query's ORDER BY clause. · The ORDER BY clause used an explcit or implicit ASC sort priority. Two examples of such a query are given here, where -a- represents an indexed column used in the table's partitioning key: 1. SELECT * FROM table WHERE a < constant ORDER BY a; 2. SELECT * FROM table WHERE a <> constant ORDER BY a; [For NDB 6.2.17:] This bug was introduced in MySQL Cluster NDB 6.2.16. [For NDB 6.3.20:] This bug was introduced in MySQL Cluster NDB 6.3.19. ----- Set bug status as NDI pending merges to NDB 6.4/mainline 5.1 and 6.0 trees.
[27 Nov 2008 14:52]
Bugs System
Pushed into 5.1.30-ndb-6.4.0 (revid:bteam@astra04-20081125020458-m0us9vykrs08b9xm) (version source revid:tomas.ulin@sun.com-20081126125958-mz5j02g2jrri8en9) (pib:5)
[27 Nov 2008 19:37]
Jon Stephens
Fix also documented in ndb-6.4.0 changelog (no changelog-specific note required this time). Returned to NDI status pending merges to mainline trees.
[8 Dec 2008 10:23]
Bugs System
Pushed into 5.1.31 (revid:mattias.jonsson@sun.com-20081124162403-pocmhhov1hji9gnk) (version source revid:patrick.crews@sun.com-20081126180318-v685u61mpgoc176x) (pib:5)
[8 Dec 2008 11:34]
Bugs System
Pushed into 6.0.9-alpha (revid:mattias.jonsson@sun.com-20081124162403-pocmhhov1hji9gnk) (version source revid:satya.bn@sun.com-20081126062231-h6os2axygjw27wb4) (pib:5)
[10 Dec 2008 22:30]
Jon Stephens
Fix now documented in the 5.1.31 and 6.0.9 changelogs, with the following notes added to above description. [In 5.1.31 entry:] This bug was introduced in MySQL 5.1.29. [In 6.0.9 entry:] This bug was introduced in MySQL 6.0.5. Closed.
[12 Dec 2008 23:30]
Bugs System
Pushed into 6.0.9-alpha (revid:bteam@astra04-20081125020458-m0us9vykrs08b9xm) (version source revid:tomas.ulin@sun.com-20081209185954-9svcixh2p5hsfi6w) (pib:5)
[28 Dec 2008 21:46]
Bugs System
Pushed into 5.1.31 (revid:joerg@mysql.com-20081228151808-aou2s7esrmastj3e) (version source revid:bteam@astra04-20081126230210-d08cnsctdfsvfag8) (merge vers: 5.1.31) (pib:6)
[19 Jan 2009 11:34]
Bugs System
Pushed into 5.1.31-ndb-6.2.17 (revid:tomas.ulin@sun.com-20090119095303-uwwvxiibtr38djii) (version source revid:tomas.ulin@sun.com-20090108105244-8opp3i85jw0uj5ib) (merge vers: 5.1.31-ndb-6.2.17) (pib:6)
[19 Jan 2009 13:10]
Bugs System
Pushed into 5.1.31-ndb-6.3.21 (revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (version source revid:tomas.ulin@sun.com-20090119104956-guxz190n2kh31fxl) (merge vers: 5.1.31-ndb-6.3.21) (pib:6)
[19 Jan 2009 16:16]
Bugs System
Pushed into 5.1.31-ndb-6.4.1 (revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (version source revid:tomas.ulin@sun.com-20090119144033-4aylstx5czzz88i5) (merge vers: 5.1.31-ndb-6.4.1) (pib:6)