Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
10.4.0
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 (MDEV-15562):
--source include/have_innodb.inc
|
create table t(a char(5) character set utf8 primary key) engine=innodb; |
alter table t add b int first; |
--let $shutdown_timeout=0;
|
--source include/restart_mysqld.inc
|
check table t; |
drop table t; |
This will result in the following errors:
10.5 a9846f329935faba560387bab8fd897102e17385 |
check table t;
|
Table Op Msg_type Msg_text
|
test.t check Error Table 'test.t' doesn't exist in engine
|
test.t check status Operation failed
|
drop table t;
|
Warnings:
|
Warning 1932 Table 'test.t' doesn't exist in engine
|
innodb.ia 'innodb' [ fail ] Found warnings/errors in server log file!
|
Test ended at 2019-11-19 21:00:04
|
line
|
2019-11-19 21:00:04 0 [ERROR] InnoDB: Table `test`.`t` contains unrecognizable instant ALTER metadata
|
2019-11-19 21:00:04 3 [ERROR] InnoDB: Table `test`.`t` contains unrecognizable instant ALTER metadata
|
2019-11-19 21:00:04 3 [ERROR] InnoDB: Table `test`.`t` contains unrecognizable instant ALTER metadata
|
2019-11-19 21:00:04 3 [ERROR] InnoDB: Table `test`.`t` does not exist in the InnoDB internal data dictionary though MariaDB is trying to drop it. Have you copied the .frm file of the table to the MariaDB database directory from another database? Please refer to https://mariadb.com/kb/en/innodb-troubleshooting/ for how to resolve the issue.
|
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():
if (!trx_id_offset) { |
/* The PRIMARY KEY contains variable-length columns. |
For the metadata record, variable-length columns are
|
always written with zero length. The DB_TRX_ID will
|
start right after any fixed-length columns. */
|
for (uint i = index->n_uniq; i--; ) { |
trx_id_offset += index->fields[i].fixed_len;
|
}
|
}
|
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.
Attachments
Issue Links
- duplicates
-
MDEV-21230 Corrupt database with MariaDB 10.4.10 (see: MDEV-20987)
- Closed
- is caused by
-
MDEV-15562 Instant DROP COLUMN or changing the order of columns
- Closed
- is duplicated by
-
MDEV-21296 Data corruption after DROP COLUMN on InnoDB tables with char primary key
- Closed
- relates to
-
MDEV-21148 mysqld: storage/innobase/btr/btr0cur.cc:507: dberr_t btr_cur_instant_init_low(dict_index_t*, mtr_t*): Assertion `index->n_core_fields + n_add >= index->n_fields' failed.
- Closed
-
MDEV-21230 Corrupt database with MariaDB 10.4.10 (see: MDEV-20987)
- Closed
-
MDEV-23119 ERROR 1932 Table doesn't exist in engine
- Closed