mysql异常重启后表crash的问题

1.背景

一台db异常重启后被切换为从库,过了一段时间后,再用pt工具做数据校验时,这台db主从断开了
错误日志:

Last_SQL_Error: Error 'Table 'game_daily_life_20220528' is marked as crashed and should be repaired' on query. 
Default database: 'statisticdb'. 
Query: 'REPLACE INTO `test1`.`checksums` (db, tbl, chunk, chunk_index, lower_boundary, upper_boundary, this_cnt, this_crc) SELECT 'statisticdb', 'game_daily_life_20220528', '9', 'PRIMARY', '1529329', '1711005', COUNT(*) AS cnt, COALESCE(LOWER(CONV(BIT_XOR(CAST(CRC32(CONCAT_WS('#', `id`, `user_id`, convert(`game_id` using utf8mb4), convert(`package_name` using utf8mb4), `create_time`, CONCAT(ISNULL(`user_id`), ISNULL(`game_id`), ISNULL(`package_name`)))) AS UNSIGNED)), 10, 16)), 0) AS crc FROM `statisticdb`.`game_daily_life_20220528` FORCE INDEX(`PRIMARY`) WHERE ((`id` >= '1529329')) AND ((`id` <= '1711005')) /*checksum chunk*/'

game_daily_life_20220528该表crash

2.解决方法

对于主从状态修复
切换域名后 kill所有来自线上用户的连接

select concat('KILL ',id,';') from information_schema.processlist where user='';

跳过错误gtid事务号

查看损坏表情况

root@statisticdb 09:30:49>check table game_daily_life_20220528;
+--------------------------------------+-------+----------+-------------------------------------------------------+
| Table                                | Op    | Msg_type | Msg_text                                              |
+--------------------------------------+-------+----------+-------------------------------------------------------+
| statisticdb.game_daily_life_20220528 | check | warning  | 1 client is using or hasn't closed the table properly |
| statisticdb.game_daily_life_20220528 | check | error    | Found 3737984 keys of 3737981                         |
| statisticdb.game_daily_life_20220528 | check | error    | Corrupt                                               |
+--------------------------------------+-------+----------+-------------------------------------------------------+

3.后期改进

db发生异常重启后 对myisam表进行check操作,查看是否有表损坏

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值