| Bug #46000 | using index called GEN_CLUST_INDEX crashes server | ||
|---|---|---|---|
| Submitted: | 7 Jul 12:57 | Modified: | 25 Nov 8:46 |
| Reporter: | Shane Bester | ||
| Status: | Patch queued | ||
| Category: | Server: InnoDB | Severity: | S1 (Critical) |
| Version: | 5.0.84, 5.1.37 | OS: | Any |
| Assigned to: | Satya B | Target Version: | 5.0+ |
| Tags: | GEN_CLUST_INDEX | ||
| Triage: | Triaged: D1 (Critical) | ||
[7 Jul 12:57]
Shane Bester
[7 Jul 13:02]
Valeriy Kravchuk
Thank you for the bug report. Verified just as described...
[8 Jul 17:05]
Michael Izioumtchenko
Vasil, could you have a look? Valeriy, all three DWI triage value seem exaggerated, how is this Critical - unaccepatable - substantial?
[9 Jul 11:57]
Calvin Sun
also see bug#44369
[21 Aug 2:16]
Jimmy Yang
InnoDB creates a default primary index called "GEN_CLUST_INDEX" in
create_clustered_index_when_no_primary(). If you create another index also called
"GEN_CLUST_INDEX", both indices created successfully, but with the same name.
When you do a select, the chosen index's metadata structure is picked by its name in
ha_innobase::records_in_range():
index = dict_table_get_index_noninline(prebuilt->table, key->name); <== key->name is the
index name.
In our case, it should select the user index, however, it got the default primary index's
metadata.
The default primary index has 4 columns (DB_ROW_ID, DB_TRX_ID, DB_ROLL_PTR, id), the user
index has 2 columns (id, DB_ROW_ID). Thus there is a column length assertion failure in
row_sel_convert_mysql_key_to_innobase(), for the column mismatch
row_sel_convert_mysql_key_to_innobase
{
....
if (dfield_get_type(dfield)->mtype == DATA_SYS) {
/* A special case: we are looking for a position in the
generated clustered index which InnoDB automatically added
to a table with no primary key: the first and the only
ordering column is ROW_ID which InnoDB stored to the key_ptr
buffer. */
ut_a(key_len == DATA_ROW_ID_LEN); <====== key_len is 5.
dfield_set_data(dfield, key_ptr, DATA_ROW_ID_LEN);
dtuple_set_n_fields(tuple, 1);
return;
}
My understanding is the Innodb does not allow duplicated index name on the same table.
Otherwise, it will be problem. So there will be a check on dup index during create index
time and that should include "GEN_CLUST_INDEX".
[10 Sep 2:51]
Jimmy Yang
We will block create any user index with "GEN_CLUST_INDEX" name.
However during the investigation, there seems an issue in mysql_alter_table() when
mysql_create_table_no_lock() call fails. The temp table are not dropped when create index
operation fails. This prevents all subsequent create index operations:
mysql> create index GEN_CLUST_INDEX on a(id);
ERROR 1005 (HY000): Can't create table 'test.#sql-62fe_1' (errno: -1)
If we do not drop the temp table table 'test.#sql-62fe_1', all subseqent create index
will fail.
mysql> create index idx on a(id);
ERROR 1005 (HY000): Can't create table 'test.#sql-62fe_1' (errno: 121)
In fact, if we make small change in mysql_alter_table(), it shall fix this:
mysql_alter_table()
{
error= mysql_create_table_no_lock(thd, new_db, tmp_name,
create_info,
alter_info,
1, 0);
reenable_binlog(thd);
if (error)
- goto err;
+ goto err1
}
Of course, there could be reasons that the code "goto err" instead of "goto err1" is
being used. However, in our case, the temp table did not get dropped as it should be.
We will drop this temp table in our innodb code. If any changes from mysql layer that
does not require us to do the drop, please inform us.
Thanks
Jimmy
[5 Oct 13:09]
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/85734 3155 Satya B 2009-10-05 Applying InnoDB snapshot 5.1-ss5921, Part 1. Fixes BUG#46000 1. BUG#46000 - using index called GEN_CLUST_INDEX crashes server Detailed revision comments: r5895 | jyang | 2009-09-15 03:39:21 +0300 (Tue, 15 Sep 2009) | 5 lines branches/5.1: Disallow creating index with the name of "GEN_CLUST_INDEX" which is reserved for the default system primary index. (Bug #46000) rb://149 approved by Marko Makela.
[6 Oct 11:00]
Bugs System
Pushed into 5.1.40 (revid:joro@sun.com-20091006073316-lea2cpijh9r6on7c) (version source revid:joro@sun.com-20091006071047-omas21geg3vdx043) (merge vers: 5.1.40) (pib:11)
[6 Oct 11:30]
Satya B
Patch queued to mysql-5.1-pe-stage. Bug still exists in 5.1 Innodb plugin/ 5.4 Innobase Disabled the test for Innodb Plugin temporarily until the patch for Innodb Plugin is applied.
[14 Oct 16:40]
Bugs System
Pushed into 5.1.41 (revid:joro@sun.com-20091014143611-cphb0enjlx6lpat1) (version source revid:satya.bn@sun.com-20091009125218-w3xkjtkhtqret6l1) (merge vers: 5.1.40) (pib:13)
[14 Oct 17:43]
Paul DuBois
Noted in 5.1.40 changelog. InnoDB did not disallow creation of an index with the name GEN_CLUST_INDEX, which is used internally. Setting report to NDI pending push into 5.5.x+.
[22 Oct 8:34]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091022063126-l0qzirh9xyhp0bpc) (version source revid:alik@sun.com-20091019135554-s1pvptt6i750lfhv) (merge vers: 6.0.14-alpha) (pib:13)
[22 Oct 9:05]
Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091022060553-znkmxm0g0gm6ckvw) (version source revid:alik@sun.com-20091019131022-2o2ymjfjjoraq833) (merge vers: 5.5.0-beta) (pib:13)
[27 Oct 16:28]
Jimmy Yang
Fix has been ported to plugin with slight different changes, due to different code path (which uses ha_innobase::add_index())for creating index in plug when comparing to 5.1. Thanks Jimmy
[4 Nov 10:25]
Bugs System
Pushed into 5.1.41 (revid:joro@sun.com-20091104092152-qz96bzlf2o1japwc) (version source revid:kristofer.pettersson@sun.com-20091103162305-08l4gkeuif2ozsoj) (merge vers: 5.1.41) (pib:13)
[5 Nov 2:52]
Paul DuBois
Noted in 5.1.41 changelog. Setting report to NDI pending push to 5.5.x.
[11 Nov 7:51]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091110093407-rw5g8dys2baqkt67) (version source revid:alik@sun.com-20091109080109-7dxapd5y5pxlu08w) (merge vers: 6.0.14-alpha) (pib:13)
[11 Nov 7:59]
Bugs System
Pushed into 5.5.0-beta (revid:alik@sun.com-20091109115615-nuohp02h8mdrz8m2) (version source revid:svoj@sun.com-20091105122958-jyqjx9xus8v4e0yd) (merge vers: 5.5.0-beta) (pib:13)
[11 Nov 15:38]
Paul DuBois
Noted in 5.5.0, 6.0.14 changelogs.
[25 Nov 10:59]
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/91554 2852 Satya B 2009-11-25 Applying InnoDB snapshot 5.0-ss6230, part 2. Fixes BUG#46000 BUG#46000 - using index called GEN_CLUST_INDEX crashes server Detailed revision comments: r6180 | jyang | 2009-11-17 10:54:57 +0200 (Tue, 17 Nov 2009) | 7 lines branches/5.0: Merge/Port fix for bug #46000 from branches/5.1 -r5895 to branches/5.0. Disallow creating index with the name of "GEN_CLUST_INDEX" which is reserved for the default system primary index. Minor adjusts on table name screening format for added tests.
