[MDEV-21088] Table cannot be loaded after instant ADD/DROP COLUMN Created: 2019-11-19 Updated: 2020-07-08 Resolved: 2019-11-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.4.0 |
| Fix Version/s: | 10.3.21, 10.4.11 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | corruption, instant | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||
| Description |
|
For a table with a variable-length encoded CHAR column in the PRIMARY KEY, the table cannot be loaded to the InnoDB data dictionary cache after instant DROP or reordering of columns (
This will result in the following errors:
The cause is that for the metadata record, we are unnecessarily writing a nonempty dummy value for the PRIMARY KEY column, even though it uses variable-length encoding. This breaks the following assumption in btr_cur_instant_init_low():
The CHAR(5) column uses a variable-length encoding in ROW_FORMAT≠REDUNDANT, occupying 5*mbminlenâ„5*mbmaxlen bytes (in this case, repeat(' ',5)). We should both stop allocating the unnecessary bytes, and adjust the above code so that the suboptimal metadata records can be parsed. |
| Comments |
| Comment by Marko Mäkelä [ 2019-11-20 ] |
|
The fix is twofold. In MariaDB 10.3, we can optimize innobase_add_instant_try() so that it avoids unnecessarily reserving space for variable-length-encoded CHAR columns in the metadata record. Tables subjected to instant ALTER TABLE with that fix should be readable by older versions of MariaDB 10.3 and 10.4. In MariaDB 10.4, we must fix btr_cur_instant_init_low() so that it will decode the actual lengths of the PRIMARY KEY columns in the metadata record. This allows the ‘corrupted’ tables to be opened by MariaDB 10.4 that contains the fix. |