Bug #108396 ERROR 1712 (HY000): Index PRIMARY is corrupted
Submitted: 6 Sep 2022 9:15 Modified: 16 Jan 19:45
Reporter: cong yang Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.26 OS:Linux
Assigned to: CPU Architecture:x86
Tags: Online DDL;virtual column;blob;

[6 Sep 2022 9:15] cong yang
Description:
Got ERROR 1712 (HY000): Index PRIMARY is corrupted while doing a online ddl operation. 

How to repeat:
1. Start mysqld server with option --debug-sync-timeout=30000000
2. Start mysql client session1 and send:
create table e1 (a int , b int , c blob, d int as (a + 1), index id(d));
insert into e1 values(1, 1, repeat('rocalrulcrcaurcuccoolrouuocacaooaucauualcucuoucucclolcllloocuarcoorlaccarocouuaoorcolloucraoaaooc',281), default);
SET DEBUG_SYNC = 'innodb_inplace_alter_table_enter SIGNAL start_create WAIT_FOR go_ahead';
alter table e1 add primary key (a);
3. Start mysql client session2 and send:
update e1 set b=2;
set debug_sync = 'now signal go_ahead';
4. session1 will get ERROR 1712 (HY000): Index PRIMARY is corrupted
[7 Sep 2022 12:35] MySQL Verification Team
Hello cong yang,

Thank you for the report and test case.

regards,
Umesh
[8 Sep 2022 8:37] huahua xu
InnoDB throws error when it applies the row_log_table log to a table upon completing rebuild.

The value of virtual column has been not write log entry, who is not changed and in an index. We shuold write all index column value or build then from cluster index record data.
[8 Sep 2022 8:39] huahua xu
I try to fix the bug by building the value of virtual column from cluster index record data

Attachment: index_corrupted_during_online_ddl.patch (application/octet-stream, text), 7.72 KiB.

[8 Sep 2022 8:48] huahua xu
In addition, the innodb performs the update by delete and insert, when if the record contains any externally stored columns. it is failed to delete secondary index entries, because there is not value of virtual column in the log entry.
[20 Sep 2022 2:42] cong yang
Thanks for the quick response. I will try to apply the patch.
[16 Jan 19:45] Philip Olson
Posted by developer:
 
Fixed as of the upcoming MySQL Server 8.0.41, 8.4.4, and 9.2.0 releases, and here's the proposed changelog entry from the documentation team for review:

Virtual column information for a row containing an externally stored BLOB
was not always logged during an UPDATE operation, which could emit an "Index
PRIMARY is corrupted" error.

Thank you for the bug report.