微信黑魔法-专注解决微信开发周边,小程序,公众号,微信机器人等技术分享

如何修复 Mysql启动失败 Innodb Error Log Sequence Number Is in the Future

如何修复 Mysql启动失败 InnoDB Error: “log sequence number is in the future”

问题背景

自动昨天暴力重启了macbook, 继上个问题 之后, 有出现了新问题, 报错如下

2020-05-10T09:34:15.839994Z 0 [ERROR] InnoDB: Page [page id: space=0, page number=205] log sequence number 4419634190 is in the future! Current system log sequence number 4414499637.
...
2020-05-10T09:34:16.044784Z 0 [ERROR] Failed to create file(file: './auto.cnf', errno 13)
2020-05-10T09:34:16.044787Z 0 [ERROR] Initialization of the server's UUID failed because it could not be read from the auto.cnf file. If this is a new server, the initialization failed because it was not possible to generate a new UUID.

解决方案

从日志看起来, 这个应该是数据断点不一致, 导致启动时候序号校验失败 有两个解决办法

1. 手动调整log sequence number

用gdb启动进程, 设置断点, 跟踪 log_sys 数据结构, 把这个值改成报错信息对应的数字即可

gdb -p pgrep -x mysqld
gdb) p log_sys->lsn
$1 = 4419634190
(gdb) set log_sys->lsn = 4414499637
(gdb) c

2. 如果数据不重要的话, 把日志文件删了重启进程也行

原文链接

参考链接

[1] https://www.percona.com/blog/2013/09/11/how-to-move-the-innodb-log-sequence-number-lsn-forward/