[MDEV-13795] ALTER TABLE…DROP PRIMARY KEY, ADD PRIMARY KEY fails when VIRTUAL columns exist Created: 2017-09-13 Updated: 2023-04-19 Resolved: 2017-11-10 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.2.2 |
| Fix Version/s: | 10.2.11, 10.3.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | corruption, online-ddl, performance, upstream, virtual_columns | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
I got a suspicion that there might be something wrong with DROP PRIMARY KEY, ADD PRIMARY KEY with ROW_FORMAT=REDUNDANT tables.
The logic is duplicated differently in row_log_table_low(), where ventry is replaced with NULL:
This turns out to be a bigger issue. I can repeat corruption and a crash with a small modification to an existing test:
I did request this kind of tests when I reviewed WL#8149 while I was employed at Oracle. In the above patch, there are a couple of ‘parameters’:
Actually, virtual columns should not matter at all for the logging of table-rebuilding ALTER TABLE operations. No matter if the columns are indexed, all that we need the values of the PRIMARY KEY and the base columns. Creating secondary indexes is a different matter. There currently exist unnecessary limitations around that (for example, adding a virtual column and adding an index is not supported in a single ALTER TABLE statement). |
| Comments |
| Comment by Marko Mäkelä [ 2017-09-13 ] | |||||||
|
Thinking deeper, this may need more effort to fix properly.
But, if there exist indexed virtual columns after the ALTER TABLE, the values of those columns must be available to row_log_table_apply(), either by evaluating the virtual column values (which could collide with
I remember another problematic scenario in MySQL 5.7 that was filed as an Oracle internal bug and probably remains open. It was something like ALTER TABLE…ADD INDEX(virtual_column) concurrently with an UPDATE that would affect the value of the virtual_column. Because the column was not indexed at the time when the UPDATE was logged, a garbage value of virtual_column would have been provided to row_log_online_op(). | |||||||
| Comment by Marko Mäkelä [ 2017-09-13 ] | |||||||
|
One more crash, indicating `online_log` corruption:
|