[MDEV-24763] ALTER TABLE fails to rename a column in SYS_FIELDS Created: 2021-02-02 Updated: 2021-02-12 Resolved: 2021-02-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.0, 10.1, 10.3.28, 10.4.18, 10.5.9, 10.6.0, 10.2 |
| Fix Version/s: | 10.2.38, 10.3.29, 10.4.19, 10.5.10 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Matthias Leich | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | corruption | ||
| Description |
|
|
| Comments |
| Comment by Elena Stepanova [ 2021-02-02 ] | |||||||||||||||
|
The failure started happening on 10.3 after this commit:
| |||||||||||||||
| Comment by Marko Mäkelä [ 2021-02-02 ] | |||||||||||||||
|
I believe that the root cause of this problem may affect 10.2 as well, but I am not sure of that yet. The provided test case does depend on The root cause why the table was not found is that innobase_rename_column_try() is looking for SYS_FIELDS.POS=4<<16 instead of SYS_FIELDS.POS=1<<16. Hence, the column was not renamed. Debugging this with INFORMATION_SCHEMA.INNODB_SYS_FIELDS is not easy, because it will not display the actual value of the POS column unless the following patch is applied:
The prefix_len is not being displayed at all. I am working on trying to find out why we are trying to look up the wrong field offset, and how to provide some more robust error handling for a dictionary corruption scenario. | |||||||||||||||
| Comment by Marko Mäkelä [ 2021-02-02 ] | |||||||||||||||
|
I do not think that we can easily fix the consequences of the bug. Even if innobase_reload_table() checked for the null pointer, we would crash in various places later due to m_prebuilt->table==NULL. The root cause is in innobase_rename_column_try(), and I think that it should affect MariaDB 10.0, 10.1, MySQL 5.6, 5.7 as well. I am working on a test case for 10.2. | |||||||||||||||
| Comment by Marko Mäkelä [ 2021-02-02 ] | |||||||||||||||
|
I repeated the root cause on 10.2:
Without the fix, the SELECT will wrongly return one row for the old column name a. The column was supposed to be renamed from a to u, but because it is not the first field in the secondary index, and because the primary key (but not the secondary index) contains a column prefix, the UPDATE SYS_FIELDS will fail to find the record with the wrong search key (INDEX_ID,POS). | |||||||||||||||
| Comment by Matthias Leich [ 2021-02-03 ] | |||||||||||||||
|
|