Bug #49250 spatial btree index corruption and crash
Submitted: 1 Dec 2009 7:42 Modified: 20 Jun 2010 22:52
Reporter: Shane Bester (Platinum Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Parser Severity:S1 (Critical)
Version:4.1.25,5.0.87,5.1.41 OS:Any
Assigned to: Georgi Kodinov CPU Architecture:Any
Tags: BTREE, corruption, spatial, valgrind

[1 Dec 2009 7:42] Shane Bester
Description:
spatial index defined as btree gets marked as corrupted and/or causes a crash and valgrind errors:

5.1.41 debug stack trace:

mysqld-debug.exe!rtree_find_req()[rt_index.c:120]
mysqld-debug.exe!rtree_find_first()[rt_index.c:198]
mysqld-debug.exe!chk_data_link()[mi_check.c:1251]
mysqld-debug.exe!ha_myisam::check()[ha_myisam.cc:833]
mysqld-debug.exe!handler::ha_check()[handler.cc:3106]
mysqld-debug.exe!mysql_admin_table()[sql_table.cc:4762]
mysqld-debug.exe!mysql_check_table()[sql_table.cc:5471]
mysqld-debug.exe!mysql_execute_command()[sql_parse.cc:2999]
mysqld-debug.exe!mysql_parse()[sql_parse.cc:5974]
mysqld-debug.exe!dispatch_command()[sql_parse.cc:1233]
mysqld-debug.exe!do_command()[sql_parse.cc:872]
mysqld-debug.exe!handle_one_connection()[sql_connect.cc:1127]
mysqld-debug.exe!pthread_start()[my_winthread.c:85]
mysqld-debug.exe!_callthreadstart()[thread.c:295]
mysqld-debug.exe!_threadstart()[thread.c:277]
kernel32.dll!BaseThreadStart()
ariables.
 invalid and cause the dump to abort...
0004C5BAA8=check table t1 extended

output on release server you can get this output, or a crash and valgrind errors also:

mysql> check table t1 extended;
+---------+-------+----------+--------------------------------------------+
| Table   | Op    | Msg_type | Msg_text                                   |
+---------+-------+----------+--------------------------------------------+
| test.t1 | check | error    | Record at: 0  Can't find key for index:  1 |
| test.t1 | check | error    | Corrupt                                    |
+---------+-------+----------+--------------------------------------------+
2 rows in set (0.00 sec)

mysql> repair table t1 extended;
+---------+--------+----------+-------------------------+
| Table   | Op     | Msg_type | Msg_text                |
+---------+--------+----------+-------------------------+
| test.t1 | repair | error    | 158 for record at pos 0 |
| test.t1 | repair | status   | Operation failed        |
+---------+--------+----------+-------------------------+
2 rows in set (0.02 sec)

How to repeat:
drop table if exists `t1`;
create table `t1`(`col1` multipolygon not null,
spatial index using btree (`col1`))engine=MyISAM;
insert ignore into t1 values ();
check table t1 extended;
repair table t1 extended;
[1 Dec 2009 7:44] MySQL Verification Team
full valgrind output of 5.1.41 showing invalid writes to memory

Attachment: bug49250_5.1.41_valgrind_output.txt (text/plain), 34.58 KiB.

[1 Dec 2009 7:48] Valeriy Kravchuk
I've got a crash on Windows XP:

 	mysqld.exe!rtree_find_req(st_myisam_info * info=0x04d3f008, st_mi_keydef * keyinfo=0x02338170, unsigned int search_flag=24576, unsigned int nod_cmp_flag=2048, unsigned __int64 page=1024, int level=0)  Line 122 + 0x2 bytes	C
 	mysqld.exe!rtree_find_first(st_myisam_info * info=0x04d3f008, unsigned int keynr=0, unsigned char * key=0x04d3fa88, unsigned int key_length=0, unsigned int search_flag=24576)  Line 197 + 0x34 bytes	C
 	mysqld.exe!chk_data_link(st_mi_check_param * param=0x05618f88, st_myisam_info * info=0x04d3f008, int extend=512)  Line 1251 + 0x1c bytes	C
 	mysqld.exe!ha_myisam::check(THD * thd=0x0230f758, st_ha_check_opt * check_opt=0x02310dec)  Line 834	C++
 	mysqld.exe!handler::ha_check(THD * thd=0x0230f758, st_ha_check_opt * check_opt=0x02310dec)  Line 3106 + 0x12 bytes	C++
 	mysqld.exe!mysql_admin_table(THD * thd=0x00000000, TABLE_LIST * tables=0x04d32708, st_ha_check_opt * check_opt=0x02310dec, const char * operator_name=0x00000000, thr_lock_type lock_type=TL_READ_NO_INSERT, bool open_for_modify=false, bool no_warnings_for_error=false, unsigned int extra_open_options=32, int (THD *, TABLE_LIST *, st_ha_check_opt *)* prepare_func=0x00000000, int (THD *, st_ha_check_opt *)* operator_func=0x0047f040, int (THD *, TABLE_LIST *)* view_operator_func=0x0054dac0)  Line 4762 + 0x1a bytes	C++
 	mysqld.exe!mysql_check_table(THD * thd=0x0230f758, TABLE_LIST * tables=0x04d32708, st_ha_check_opt * check_opt=0x02310dec)  Line 5471 + 0x2e bytes	C++
 	mysqld.exe!mysql_execute_command(THD * thd=0x0230f758)  Line 2999 + 0x17 bytes	C++
...
[2 Dec 2009 3:13] MySQL Verification Team
4.1.25 also affected.
[8 Dec 2009 14:32] Georgi Kodinov
Spatial indexes should not allow specifying index type. Moving to "Parser".
[8 Dec 2009 17: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/93244

2861 Georgi Kodinov	2009-12-08
      Bug #49250 : spatial btree index corruption and crash
      
      SPATIAL and FULLTEXT indexes don't support algorithm
      selection. 
      Disabled by creating a special grammar rule for these
      in the parser.
[9 Dec 2009 11:18] 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/93301

2861 Georgi Kodinov	2009-12-09
      Bug #49250 : spatial btree index corruption and crash
      
      SPATIAL and FULLTEXT indexes don't support algorithm
      selection. 
      Disabled by creating a special grammar rule for these
      in the parser.
[10 Dec 2009 9:28] 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/93458

2861 Georgi Kodinov	2009-12-10
      Bug #49250 : spatial btree index corruption and crash
      
      SPATIAL and FULLTEXT indexes don't support algorithm
      selection. 
      Disabled by creating a special grammar rule for these
      in the parser.
      Added some encasulation of duplicate parser code.
[10 Dec 2009 15:50] 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/93551

2866 Georgi Kodinov	2009-12-10
      Bug #49250 : spatial btree index corruption and crash
      
      SPATIAL and FULLTEXT indexes don't support algorithm
      selection. 
      Disabled by creating a special grammar rule for these
      in the parser.
      Added some encasulation of duplicate parser code.
[11 Dec 2009 14:04] 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/93692

3259 Georgi Kodinov	2009-12-11 [merge]
      merge of bug #49250 to 5.1-bugteam
[19 Dec 2009 8:28] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091219082307-f3i4fn0tm8trb3c0) (version source revid:alik@sun.com-20091216180721-eoa754i79j4ssd3m) (merge vers: 6.0.14-alpha) (pib:15)
[19 Dec 2009 8:32] Bugs System
Pushed into 5.5.1-m2 (revid:alik@sun.com-20091219082021-f34nq4jytwamozz0) (version source revid:alexey.kopytov@sun.com-20091216134707-o96eqw0u2ynvo9gm) (merge vers: 5.5.0-beta) (pib:15)
[19 Dec 2009 8:36] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20091219082213-nhjjgmphote4ntxj) (version source revid:alik@sun.com-20091216180221-a5ps59gajad3pip9) (pib:15)
[8 Jan 2010 1:09] Paul DuBois
Noted in 5.5.1, 6.0.14 changelogs.

Specifying an index algorithm (such as BTREE) for SPATIAL or FULLTEXT
indexes caused a server crash. These index types do not support 
algorithm specification, and it is now disallowed to do so.  

Setting report to NDI pending push to Celosia.
[14 Jan 2010 8:27] Bugs System
Pushed into 5.0.90 (revid:joro@sun.com-20100114082402-05fod2h6z9x9wok8) (version source revid:aelkin@mysql.com-20091214144410-630vanwyllvvacad) (merge vers: 5.0.89) (pib:16)
[14 Jan 2010 18:31] Paul DuBois
Noted in 5.0.90 changelog.

Setting report to NDI pending push to 5.1.x, Celosia.
[15 Jan 2010 9:02] Bugs System
Pushed into 5.1.43 (revid:joro@sun.com-20100115085139-qkh0i0fpohd9u9p5) (version source revid:joro@sun.com-20091211140247-s2i35alqoezku2qi) (merge vers: 5.1.42) (pib:16)
[15 Jan 2010 18:40] Paul DuBois
Noted in 5.1.43 changelog.

Setting report to NDI pending push to Celosia.
[17 Feb 2010 16:29] Paul DuBois
Noted in 5.0.87sp1 changelog.
[20 Feb 2010 17:11] Bugs System
Pushed into 5.0.91 (revid:build@mysql.com-20100220170835-5kr6ztsg25va7qzz) (version source revid:build@mysql.com-20100220170835-5kr6ztsg25va7qzz) (merge vers: 5.0.91) (pib:16)
[1 Mar 2010 8:45] Bugs System
Pushed into 5.1.45 (revid:joro@sun.com-20100301083827-xnimmrjg6bh33o1o) (version source revid:joro@sun.com-20100226131646-kpvzk740hxbtaexn) (merge vers: 5.1.45) (pib:16)
[2 Mar 2010 14:36] Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100302142746-u1gxdf5yk2bjrq3e) (version source revid:alik@sun.com-20100301095421-4cz64ibem1h2quve) (merge vers: 6.0.14-alpha) (pib:16)
[2 Mar 2010 14:40] Bugs System
Pushed into 5.5.3-m2 (revid:alik@sun.com-20100302072233-t3uqgjzdukt1pyhe) (version source revid:alik@sun.com-20100301090215-63o2w2y16go8n53p) (merge vers: 5.5.3-m2) (pib:16)
[2 Mar 2010 14:45] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100302072432-k8xvfkgcggkwgi94) (version source revid:alik@sun.com-20100301094536-2zc4uqyy3os8san7) (pib:16)
[12 Mar 2010 14:15] Bugs System
Pushed into 5.1.44-ndb-7.0.14 (revid:jonas@mysql.com-20100312135944-t0z8s1da2orvl66x) (version source revid:jonas@mysql.com-20100312115609-woou0te4a6s4ae9y) (merge vers: 5.1.44-ndb-7.0.14) (pib:16)
[12 Mar 2010 14:31] Bugs System
Pushed into 5.1.44-ndb-6.2.19 (revid:jonas@mysql.com-20100312134846-tuqhd9w3tv4xgl3d) (version source revid:jonas@mysql.com-20100312060623-mx6407w2vx76h3by) (merge vers: 5.1.44-ndb-6.2.19) (pib:16)
[12 Mar 2010 14:47] Bugs System
Pushed into 5.1.44-ndb-6.3.33 (revid:jonas@mysql.com-20100312135724-xcw8vw2lu3mijrhn) (version source revid:jonas@mysql.com-20100312103652-snkltsd197l7q2yg) (merge vers: 5.1.44-ndb-6.3.33) (pib:16)
[12 Mar 2010 16:40] Paul DuBois
Fixed in earlier 5.1.x, 5.5.x.
[17 Jun 2010 12:01] Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 12:43] Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:martin.skold@mysql.com-20100609140708-52rvuyq4q500sxkq) (merge vers: 5.1.45-ndb-6.2.19) (pib:16)
[17 Jun 2010 13:29] Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)