mysql索引损坏,Record in index `log_time` of table `lts`.`lts_job_log_po` was not found on update

Posted 郭大侠

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了mysql索引损坏,Record in index `log_time` of table `lts`.`lts_job_log_po` was not found on update相关的知识,希望对你有一定的参考价值。

【1】错误信息

[ERROR] [MY-012869] [InnoDB] Record in index `log_time` of table `lts`.`lts_job_log_po` was not found on update: TUPLE (info_bits=0, 2 n_cmp=2, fields)

2023-05-29T23:03:05.146242Z 193 [ERROR] [MY-013183] [InnoDB] Assertion failure: row0upd.cc:2358:0 thread 140238624069376
InnoDB: We intentionally generate a memory trap.
InnoDB: Submit a detailed bug report to http://bugs.mysql.com.
InnoDB: If you get repeated assertion failures or crashes, even
InnoDB: immediately after the mysqld startup, there may be
InnoDB: corruption in the InnoDB tablespace. Please refer to
InnoDB: http://dev.mysql.com/doc/refman/8.0/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
23:03:05 UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.

【2】处理办法

初步确定为因为名为 t_idx 的索引损坏导致的大量报错,并在处理 update 语句时导致 crash。

(1)确认表有错误

  CHECK TABLE `$db_name`.`$tb_name`; 

(2)修复

方式1:optimize table `$db_name`.`$tb_name`; 

方式2:alter table  `$db_name`.`$tb_name` engine=innodb;

mysql强制索引和禁止某个索引

1、mysql强制使用索引:force index(索引名或者主键PRI)

例如:

select * from table force index(PRI) limit 2;(强制使用主键)

select * from table force index(ziduan1_index) limit 2;(强制使用索引"ziduan1_index")

select * from table force index(PRI,ziduan1_index) limit 2;(强制使用索引"PRI和ziduan1_index")

 

2、mysql禁止某个索引:ignore index(索引名或者主键PRI)

例如:

select * from table ignore index(PRI) limit 2;(禁止使用主键)

select * from table ignore index(ziduan1_index) limit 2;(禁止使用索引"ziduan1_index")

select * from table ignore index(PRI,ziduan1_index) limit 2;(禁止使用索引"PRI,ziduan1_index")

以上是关于mysql索引损坏,Record in index `log_time` of table `lts`.`lts_job_log_po` was not found on update的主要内容,如果未能解决你的问题,请参考以下文章

mysql in 会使用索引吗

修改索引名称(mysql)

mysql强制索引和禁止某个索引

PHP Yii:在Active Record中使用MySQL的IN条件

MySQL索引类型

mysql找到所有索引