[MDEV-17468] Avoid table rebuild on operations on generated columns Created: 2018-10-16 Updated: 2023-11-03 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.2, 10.3, 10.4 |
| Fix Version/s: | 10.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Thirunarayanan Balathandayuthapani |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | ddl, instant, virtual_columns | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
When MySQL 5.7 introduced indexed virtual columns in InnoDB, it added many limitations around ALTER TABLE…ALGORITHM=INPLACE. One of them is that altering or adding virtual columns is not supported when the same ALTER TABLE statement is also adding, dropping or reordering stored columns. MariaDB 10.2 inherited these limitations in In I ran into trouble with the following in the test gcol.innodb_virtual_basic, around line 541:
The problem is that instant ADD of persistent columns ( In this case, we should be able to avoid a table rebuild, and instantly add both columns, then generate the values for the stored column. Furthermore, there is the function check_v_col_in_order() whose sole purpose is to refuse operations that would change the order of virtual columns. This function should be removed and the code be fixed. Last but not least, the function ha_innobase::commit_inplace_alter_table() is evicting and reloading the table definition if any virtual columns were added or dropped. This code does not appear to work for partitioned tables (or it is only operating on the first partition or subpartition of the table). It is causing an expensive operation of emptying the adaptive hash index. The purpose of the exercise seems to be to invoke dict_load_column_low(), which is the only place where num_base for virtual columns is assigned to nonzero. It would be better to update this field directly in the data dictionary cache. |
| Comments |
| Comment by Marko Mäkelä [ 2018-10-18 ] | ||||||||||||||||||||||||||||||||||
|
To make the situation worse, in
Before Occasionally, there would be a crash in purge, if purge gets a chance to run before the drop table. Adding --sleep 1 or wait_all_purged.inc did not improve the chances for me. You will have to repeat the test many times and run multiple instances of it in parallel, to get a crash. It never crashed for me on 10.2 or 10.3. I saw two types of crashes:
and another:
ASAN did not flag anything. I tried both with and without it. Due to this, until this bug has been fixed, 10.4 will have a regression compared to 10.3: instant ADD COLUMN (at the end of the column list) will not be supported if indexed virtual columns exist. | ||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2018-10-18 ] | ||||||||||||||||||||||||||||||||||
|
The second one looks much like |