[MDEV-21296] Data corruption after DROP COLUMN on InnoDB tables with char primary key Created: 2019-12-12  Updated: 2019-12-12  Resolved: 2019-12-12

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.4.10
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Dominik Leibenger Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Environment:

10.4.10-MariaDB-log - mariadb.org binary distribution on Windows 10 (1909)


Issue Links:
Duplicate
duplicates MDEV-21088 Table cannot be loaded after instant ... Closed

 Description   

When an InnoDB table has a char field with a UTF8 collation which is set as primary key, dropping a column seems to cause data corruption.

The problem can be reproduced on a fresh database by executing the following queries:

CREATE TABLE example (
  id char(8) COLLATE utf8mb4_bin NOT NULL,
  extra_column int NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB;
 
ALTER TABLE example DROP COLUMN extra_column;

The altered table keeps working fine until the MariaDB server is restarted. But after restart, attempts to access the table result in the following error:

#1932 - Table 'test.example' doesn't exist in engine

mysql_error.log excerpt:

2019-12-12 1:19:55 25 [ERROR] InnoDB: Table `test`.`example` contains unrecognizable instant ALTER metadata

The problem seems to occur only if the data type of the primary key column is char and only for certain collations (utf8mb4_bin, utf8_bin, utf8_unicode_ci, ...), but for any lengths. The data type of the column that is dropped does not seem to matter.

I presume this bug is related to the alter algorithm: It occurs with DEFAULT, INPLACE, NOCOPY and INSTANT, but not with COPY, i.e., the problem can be avoided by executing

SET SESSION alter_algorithm='COPY';

before running the ALTER query. If the table has already been altered but the MariaDB server has not yet been restarted, recreating the table via

OPTIMIZE TABLE example;

seems to prevent the mentioned data corruption.



 Comments   
Comment by Alice Sherepa [ 2019-12-12 ]

Thanks for the report! It is the same bug as MDEV-21088, fixed in 10.4.11

Generated at Thu Feb 08 09:06:04 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.