解决InnoDB: Failing assertion: !lock->recursive
背景:
在arm服务器里运行MySQL5.7.22版本
报错信息 :
2024-11-25T08:07:36.241825+08:00 856 [Note] Multi-threaded slave statistics for channel '': seconds elapsed = 126; events assigned = 53431297; worker queues filled over overrun level = 0; waited due a Worker queue full = 0; waited due the total size = 0; waited at clock conflicts = 894612095100 waited (count) when Workers occupied = 76 waited when Workers occupied = 36574500
2024-11-25T08:09:36.383649+08:00 856 [Note] Multi-threaded slave statistics for channel '': seconds elapsed = 120; events assigned = 53462017; worker queues filled over overrun level = 0; waited due a Worker queue full = 0; waited due the total size = 0; waited at clock conflicts = 894781573600 waited (count) when Workers occupied = 76 waited when Workers occupied = 36574500
2024-11-25 08:10:43 0xffaa167160e0 InnoDB: Assertion failure in thread 281105986052320 in file sync0rw.cc line 560
InnoDB: Failing assertion: !lock->recursive
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.7/en/forcing-innodb-recovery.html
InnoDB: about forcing recovery.
00:10:43 UTC - 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.
Attempting to collect some information that could help diagnose the problem.
As this is a crash and something is definitely wrong, the information
collection process might fail.key_buffer_size=33554432
read_buffer_size=2097152
max_used_connections=4
max_threads=64020
thread_count=18
connection_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 394231416 K bytes of memory
Hope that's ok; if not, decrease some variables in the equation.Thread pointer: 0xffa990007f70
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...
stack_bottom = ffaa167157a0 thread_stack 0x30000
/export/servers/app/mysql-5.7.22/bin/mysqld(my_print_stacktrace+0x2c)[0xd907ec]
/export/servers/app/mysql-5.7.22/bin/mysqld(handle_fatal_signal+0x39c)[0x70dcdc]
linux-vdso.so.1(__kernel_rt_sigreturn+0x0)[0xffffa93ef8ec]
/usr/lib64/libc.so.6(+0x80df8)[0xffffa8f2cdf8]
/usr/lib64/libc.so.6(raise+0x1c)[0xffffa8ee8cbc]
/usr/lib64/libc.so.6(abort+0xe0)[0xffffa8ed6cec]
/export/servers/app/mysql-5.7.22/bin/mysqld[0x6e55bc]
/export/servers/app/mysql-5.7.22/bin/mysqld[0xef7908]
/export/servers/app/mysql-5.7.22/bin/mysqld(_Z16buf_page_get_genRK9page_id_tRK11page_size_tmP11buf_block_tmPKcmP5mtr_tb+0x664)[0xf75ac4]
/export/servers/app/mysql-5.7.22/bin/mysqld(_Z20btr_cur_latch_leavesP11buf_block_tRK9page_id_tRK11page_size_tmP9btr_cur_tP5mtr_t+0x58c)[0xf5323c]
/export/servers/app/mysql-5.7.22/bin/mysqld(_Z27btr_cur_search_to_nth_levelP12dict_index_tmPK8dtuple_t15page_cur_mode_tmP9btr_cur_tmPKcmP5mtr_t+0x12a8)[0xf59848]
/export/servers/app/mysql-5.7.22/bin/mysqld(_Z30btr_pcur_restore_position_funcmP10btr_pcur_tPKcmP5mtr_t+0x120)[0xf607f0]
/export/servers/app/mysql-5.7.22/bin/mysqld[0xed3ca4]
/export/servers/app/mysql-5.7.22/bin/mysqld[0xed84e4]
/export/servers/app/mysql-5.7.22/bin/mysqld(_Z7row_updP10upd_node_tP9que_thr_t+0x230)[0xed8e40]
/export/servers/app/mysql-5.7.22/bin/mysqld(_Z12row_upd_stepP9que_thr_t+0x68)[0xed8f08]
/export/servers/app/mysql-5.7.22/bin/mysqld[0xea6318]
/export/servers/app/mysql-5.7.22/bin/mysqld(_ZN11ha_innobase10update_rowEPKhPh+0x148)[0xdd3f58]
/export/servers/app/mysql-5.7.22/bin/mysqld(_ZN7handler13ha_update_rowEPKhPh+0x198)[0x7566fc]
/export/servers/app/mysql-5.7.22/bin/mysqld(_ZN21Update_rows_log_event11do_exec_rowEPK14Relay_log_info+0x84)[0xd06984]
/export/servers/app/mysql-5.7.22/bin/mysqld(_ZN14Rows_log_event12do_apply_rowEPK14Relay_log_info+0x2c)[0xd034fc]
/export/servers/app/mysql-5.7.22/bin/mysqld(_ZN14Rows_log_event24do_index_scan_and_updateEPK14Relay_log_info+0x218)[0xd14378]
/export/servers/app/mysql-5.7.22/bin/mysqld(_ZN14Rows_log_event14do_apply_eventEPK14Relay_log_info+0x6d0)[0xd13994]
/export/servers/app/mysql-5.7.22/bin/mysqld(_Z27slave_worker_exec_job_groupP12Slave_workerP14Relay_log_info+0x1e4)[0xd6cac4]
/export/servers/app/mysql-5.7.22/bin/mysqld(handle_slave_worker+0x2b4)[0xd504d4]
/export/servers/app/mysql-5.7.22/bin/mysqld(pfs_spawn_thread+0xf4)[0x10a4784]
/usr/lib64/libc.so.6(+0x7f320)[0xffffa8f2b320]
/usr/lib64/libc.so.6(+0xe545c)[0xffffa8f9145c]Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (ffa99ce9c970): is an invalid pointer
Connection ID (thread ID): 858
Status: NOT_KILLEDThe manual page at http://dev.mysql.com/doc/mysql/en/crashing.html contains
information that should help you find out what is causing the crash.
2024-11-25T08:10:47.554095+08:00 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2024-11-25T08:10:47.554214+08:00 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2024-11-25T08:10:47.554246+08:00 0 [Note] /export/servers/app/mysql-5.7.22/bin/mysqld (mysqld 5.7.22-log) starting as process 41346 ...
2024-11-25T08:10:47.599043+08:00 0 [Warning] option 'innodb-buffer-pool-instances': unsigned value 128 adjusted to 64
2024-11-25T08:10:47.599739+08:00 0 [Warning] InnoDB: Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
2024-11-25T08:10:47.599768+08:00 0 [Warning] InnoDB: Using innodb_file_format_max is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
2024-11-25T08:10:47.599859+08:00 0 [Note] InnoDB: PUNCH HOLE support available
2024-11-25T08:10:47.599871+08:00 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2024-11-25T08:10:47.599877+08:00 0 [Note] InnoDB: Uses event mutexes
2024-11-25T08:10:47.599881+08:00 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2024-11-25T08:10:47.599885+08:00 0 [Note] InnoDB: Compressed tables use zlib 1.2.3
2024-11-25T08:10:47.599890+08:00 0 [Note] InnoDB: Using Linux native AIO
2024-11-25T08:10:47.623089+08:00 0 [Note] InnoDB: Number of pools: 1
2024-11-25T08:10:47.623284+08:00 0 [Note] InnoDB: Not using CPU crc32 instructions
2024-11-25T08:10:47.625617+08:00 0 [Note] InnoDB: Initializing buffer pool, total size = 328G, instances = 64, chunk size = 128M
2024-11-25T08:11:10.620091+08:00 0 [Note] InnoDB: Completed initialization of buffer pool
2024-11-25T08:11:13.781206+08:00 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2024-11-25T08:11:13.785464+08:00 0 [Note] InnoDB: Opened 2 undo tablespaces
2024-11-25T08:11:13.785498+08:00 0 [Note] InnoDB: 2 undo tablespaces made active
2024-11-25T08:11:13.785805+08:00 0 [Note] InnoDB: Highest supported file format is Barracuda.
2024-11-25T08:11:16.304842+08:00 0 [Note] InnoDB: Log scan progressed past the checkpoint lsn 185967007381
2024-11-25T08:11:16.426612+08:00 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 185972250112
官方说明:
https://bugs.mysql.com/bug.php?id=94699
https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-27.html
属于漏洞,已经在新版本里修复了
其他修复方案:
1、调大slave_pending_jobs_size_max
如果slave_pending_jobs_size_max的大小小于当前需要执行事件所需的内存大小
2、临时调整sync_binlog大小
当每进行n次事务提交之后,MySQL将进行一次fsync之类的磁盘同步指令来将binlog_cache中的数据强制写入磁盘
3、slave_parallel_workers
调整并行复制的参数,建议修改为cpu的核数
4、innodb_io_capacity
sas硬盘建议200,如果是nvme固态盘,建议调整为1500