环境:galera cluster,两节点:192.168.117.82/83,
一、故障原因:
修改一个大表(40G)的字段类型时,数据库进程崩溃:
alter table bd_order_detail modify dlr_id varchar(40);
二、日志如下:
180713 13:56:44 [ERROR] Event Scheduler: [jyldtest@%][jyld.ev_supplier_ld] Lock wait timeout exceeded; try restarting transaction
180713 13:56:44 [ERROR] Event Scheduler: [jyldtest@%][jyld.ev_supplier_ld] Lock wait timeout exceeded; try restarting transaction
180713 13:56:44 [Note] Event Scheduler: [jyldtest@%].[jyld.ev_supplier_ld] event execution failed.
180713 13:56:44 [ERROR] Event Scheduler: [jyldtest@%][jyld.ev_good_hjy] Lock wait timeout exceeded; try restarting transaction
180713 13:56:44 [ERROR] Event Scheduler: [jyldtest@%][jyld.ev_good_hjy] Lock wait timeout exceeded; try restarting transaction
180713 13:56:44 [Note] Event Scheduler: [jyldtest@%].[jyld.ev_good_hjy] event execution failed.
180713 13:56:44 [ERROR] Event Scheduler: [jyldtest@%][jyld.ev_good_ld] Lock wait timeout exceeded; try restarting transaction
180713 13:56:44 [ERROR] Event Scheduler: [jyldtest@%][jyld.ev_good_ld] Lock wait timeout exceeded; try restarting transaction
180713 13:56:44 [Note] Event Scheduler: [jyldtest@%].[jyld.ev_good_ld] event execution failed.
180713 13:56:44 [ERROR] Event Scheduler: [jyldtest@%][jyld.ev_supplier_hjy] Lock wait timeout exceeded; try restarting transaction
180713 13:56:44 [ERROR] Event Scheduler: [jyldtest@%][jyld.ev_supplier_hjy] Lock wait timeout exceeded; try restarting transaction
180713 13:56:44 [Note] Event Scheduler: [jyldtest@%].[jyld.ev_supplier_hjy] event execution failed.
180713 14:02:48 [ERROR] mysqld got signal 11 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
To report this bug, see http://kb.askmonty.org/en/reporting-bugs
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.
Server version: 10.0.24-MariaDB-wsrep
key_buffer_size=33554432
read_buffer_size=33554432
2018-07-13 14:02:48 7f64fa530700max_used_connections=33
InnoDB: Assertion failure in thread 140071673202432 in file trx0trx.cc line 1821
max_threads=3002
InnoDB: Failing assertion: trx->lock.n_active_thrs == 1
thread_count=37
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/5.6/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 104611053 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
Thread pointer: 0x0x7f5dfe6d4008
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Fatal signal 6 while backtracing
三、再次启动:
/usr/bin/mysqld_safe --defaults-file=/etc/my.cnf --datadir=/home/mysql --wsrep-new-cluster &
失败,查看日志:
180713 14:14:19 [Note] InnoDB: Initializing buffer pool, size = 10.0G
180713 14:14:25 [Note] InnoDB: Completed initialization of buffer pool
180713 14:14:26 [Note] InnoDB: Highest supported file format is Barracuda.
180713 14:14:26 [Note] InnoDB: The log sequence numbers 1169252937385 and 1169252937385 in ibdata files do not match the log sequence number 1611631098892 in the ib_logfiles!
180713 14:14:26 [Note] InnoDB: Database was not shutdown normally!
180713 14:14:26 [Note] InnoDB: Starting crash recovery.
180713 14:14:26 [Note] InnoDB: Reading tablespace information from the .ibd files...
180713 14:14:26 [Note] InnoDB: Restoring possible half-written data pages
180713 14:14:26 [Note] InnoDB: from the doublewrite buffer...
InnoDB: Last MySQL binlog file position 0 330399181, file name /home/mysql/mysql-bin.000671
2018-07-13 14:14:28 7f93af750820 InnoDB: Error: table 'jybd/bd_order_detail'
InnoDB: in InnoDB data dictionary has tablespace id 1365,
InnoDB: but the tablespace with that id has name jybd/#sql-26e34_14c35.
InnoDB: Have you deleted or moved .ibd files?
InnoDB: There is a tablespace with the right name
InnoDB: 'jybd/bd_order_detail', but its id is 1170.
InnoDB: Please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/innodb-troubleshooting-datadict.html
InnoDB: for how to resolve the issue.
180713 14:14:28 [Note] InnoDB: 128 rollback segment(s) are active.
180713 14:14:28 [Note] InnoDB: Waiting for purge to start
180713 14:14:28 [ERROR] InnoDB: InnoDB: Unable to allocate memory of size 18446744073709543768.
2018-07-13 14:14:28 7f8ce71fc700 InnoDB: Assertion failure in thread 140243149768448 in file ha_innodb.cc line 20586
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/5.6/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
180713 14:14:28 [ERROR] mysqld got signal 6 ;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
To report this bug, see http://kb.askmonty.org/en/reporting-bugs
We will try our best to scrape up some info that will hopefully help
diagnose the problem, but since we have already crashed,
something is definitely wrong and this may fail.
Server version: 10.0.24-MariaDB-wsrep
key_buffer_size=33554432
read_buffer_size=33554432
max_used_connections=0
max_threads=3002
thread_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 104611053 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
可以看到,表bd_order_detail表的数据文件已经损坏、重做日志损坏。此时,另一个节点117.83重启后报同样的错。
解决:
多次修改参数启动无果后,进行强制恢复:innodb_force_recovery=5
1(SRV_FORCE_IGNORE_CORRUPT):忽略检查到的corrupt页。
2(SRV_FORCE_NO_BACKGROUND):阻止主线程的运行,如主线程需要执行full purge操作,会导致crash。
3(SRV_FORCE_NO_TRX_UNDO):不执行事务回滚操作。
4(SRV_FORCE_NO_IBUF_MERGE):不执行插入缓冲的合并操作。
5(SRV_FORCE_NO_UNDO_LOG_SCAN):不查看重做日志,InnoDB存储引擎会将未提交的事务视为已提交。
6(SRV_FORCE_NO_LOG_REDO):不执行前滚的操作。
此时数据库以只读模式启动,进行mysqldump导出,此时导出的数据并非完整数据,因为重做日志文件已经损坏了:
mysqldump -uroot -p --default-character-set=utf8 --skip-lock-tables --hex-blob=true -E -R --all-databases > /home/all_0819.sql
重新搭建galera cluster后将sql文件导入。
启动数据库后恢复正常。