首页 > 解决方案 > mysqld 在运行简单查询时收到信号 6

问题描述

我已经开始让mysql崩溃并重新启动。系统已经完全稳定,这在创建下表后开始发生。我使用INSERT INTO命令成功插入了大约 210,000 条记录。但后来我注意到在运行简单的和INSERT命令时服务器出现故障。UPDATESELECT

例如,当我运行以下查询时服务器崩溃了:SELECT * FROM tipstrade_2.tblVehicleLookups limit 1

任何识别问题的提示将不胜感激。

CREATE TABLE `tblVehicleLookups` (
  `fldID` int(11) NOT NULL AUTO_INCREMENT,
  `fldTicketID` char(12) NOT NULL,
  `fldVRM` varchar(10) NOT NULL,
  `fldVIN` char(17) NOT NULL,
  `fldMake` varchar(32) NOT NULL,
  `fldModel` varchar(32) NOT NULL,
  `fldVehicle` varchar(255) NOT NULL,
  `fldDiscriminator` varchar(255) NOT NULL,
  `fldData` text NOT NULL,
  `fldPrice` decimal(5,2) DEFAULT NULL,
  `fldFreeAfter` date NOT NULL DEFAULT '0001-01-01',
  `fldIsFree` bit(1) GENERATED ALWAYS AS (`fldFreeAfter` < cast(current_timestamp() as date)) VIRTUAL,
  `fldCreated` datetime NOT NULL DEFAULT current_timestamp(),
  `fldModified` datetime DEFAULT NULL ON UPDATE current_timestamp(),
  `fldCarWebID` int(11) DEFAULT NULL,
  PRIMARY KEY (`fldID`),
  UNIQUE KEY `fldCarWebID` (`fldCarWebID`),
  KEY `fldVRM` (`fldVRM`),
  KEY `fldVIN` (`fldVIN`)
) ENGINE=InnoDB AUTO_INCREMENT=1310702 DEFAULT CHARSET=utf8

错误日志

pure virtual method called
terminate called without an active exception
210215 13:12:40 [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 https://mariadb.com/kb/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.2.36-MariaDB-10.2.36+maria~xenial-log
key_buffer_size=1073741824
read_buffer_size=2097152
max_used_connections=152
max_threads=202
thread_count=153
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 2087104 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

Thread pointer: 0x7f016c0009a8
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 = 0x7f039d60fcc8 thread_stack 0x49000
/usr/sbin/mysqld(my_print_stacktrace+0x2e)[0x561b050f699e]
/usr/sbin/mysqld(handle_fatal_signal+0x305)[0x561b04ba90d5]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x11390)[0x7f0831b60390]
linux/raise.c:54(__GI_raise)[0x7f083112f438]
stdlib/abort.c:91(__GI_abort)[0x7f083113103a]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x16d)[0x7f083185c84d]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8d6b6)[0x7f083185a6b6]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8d701)[0x7f083185a701]
/usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8e23f)[0x7f083185b23f]
/usr/sbin/mysqld(_ZN4Item24get_date_with_conversionEP13st_mysql_timey+0x31)[0x561b04bbdf21]
/usr/sbin/mysqld(+0x459aaa)[0x561b04978aaa]
/usr/sbin/mysqld(_ZN14Arg_comparator16compare_temporalE16enum_field_types+0x4b)[0x561b04bdc09b]
/usr/sbin/mysqld(_ZN12Item_func_lt7val_intEv+0x2f)[0x561b04bd3abf]
/usr/sbin/mysqld(_ZN4Item13save_in_fieldEP5Fieldb+0x15c)[0x561b04bb86cc]
/usr/sbin/mysqld(_ZN5TABLE21update_virtual_fieldsEP7handler21enum_vcol_update_mode+0x13b)[0x561b04aba0bb]
/usr/sbin/mysqld(_ZN7handler11ha_rnd_nextEPh+0x1ba)[0x561b04badada]
/usr/sbin/mysqld(_Z13rr_sequentialP11READ_RECORD+0x35)[0x561b04cb7cc5]
/usr/sbin/mysqld(_Z10sub_selectP4JOINP13st_join_tableb+0x164)[0x561b04a3e5e4]
/usr/sbin/mysqld(_ZN4JOIN10exec_innerEv+0xb8b)[0x561b04a5e76b]
/usr/sbin/mysqld(_ZN4JOIN4execEv+0x33)[0x561b04a5e973]
/usr/sbin/mysqld(_Z12mysql_selectP3THDP10TABLE_LISTjR4ListI4ItemEPS4_jP8st_orderS9_S7_S9_yP13select_resultP18st_select_lex_unitP13st_select_lex+0xeb)[0x561b04a5eabb]
/usr/sbin/mysqld(_Z13handle_selectP3THDP3LEXP13select_resultm+0x12f)[0x561b04a5f3cf]
/usr/sbin/mysqld(+0x41b779)[0x561b0493a779]
/usr/sbin/mysqld(_Z21mysql_execute_commandP3THD+0x32ac)[0x561b04a08d5c]
/usr/sbin/mysqld(_Z11mysql_parseP3THDPcjP12Parser_statebb+0x26e)[0x561b04a0e24e]
/usr/sbin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcjbb+0xba6)[0x561b04a0fb26]
/usr/sbin/mysqld(_Z10do_commandP3THD+0x10c)[0x561b04a1184c]
/usr/sbin/mysqld(_Z24do_handle_one_connectionP7CONNECT+0x272)[0x561b04adfae2]
/usr/sbin/mysqld(handle_one_connection+0x3d)[0x561b04adfc3d]
/usr/sbin/mysqld(+0x818891)[0x561b04d37891]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x76ba)[0x7f0831b566ba]
x86_64/clone.S:111(clone)[0x7f08312014dd]

Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7f016c00f120): SELECT * FROM tipstrade_2.tblVehicleLookups
limit 1

Connection ID (thread ID): 8202
Status: NOT_KILLED

Optimizer switch: index_merge=on,index_merge_union=on,index_merge_sort_union=on,index_merge_intersection=on,index_merge_sort_intersection=off,engine_condition_pushdown=off,index_condition_pushdown=on,derived_merge=on,derived_with_keys=on,firstmatch=on,loosescan=on,materialization=on,in_to_exists=on,semijoin=on,partial_match_rowid_merge=on,partial_match_table_scan=on,subquery_cache=on,mrr=off,mrr_cost_based=off,mrr_sort_keys=off,outer_join_with_cache=on,semijoin_with_cache=on,join_cache_incremental=on,join_cache_hashed=on,join_cache_bka=on,optimize_join_buffer_size=off,table_elimination=on,extended_keys=on,exists_to_in=on,orderby_uses_equalities=on,condition_pushdown_for_derived=on

The manual page at https://mariadb.com/kb/en/how-to-produce-a-full-stack-trace-for-mysqld/ contains
information that should help you find out what is causing the crash.
Writing a core file...
Working directory at /home/mysql
Resource Limits:
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            8388608              unlimited            bytes     
Max core file size        0                    unlimited            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             256349               256349               processes 
Max open files            65533                65533                files     
Max locked memory         65536                65536                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       256349               256349               signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0                    
Max realtime timeout      unlimited            unlimited            us        
Core pattern: |/usr/share/apport/apport %p %s %c %d %P %E

2021-02-15 13:12:51 140611253319872 [Note] Using unique option prefix 'myisam_recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Uses event mutexes
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Compressed tables use zlib 1.2.8
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Using Linux native AIO
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Number of pools: 1
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Using SSE2 crc32 instructions
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Initializing buffer pool, total size = 16G, instances = 16, chunk size = 128M
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Completed initialization of buffer pool
2021-02-15 13:12:51 140591352649472 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Highest supported file format is Barracuda.
2021-02-15 13:12:51 140611253319872 [Note] InnoDB: Starting crash recovery from checkpoint LSN=513506676876
2021-02-15 13:12:52 140611253319872 [Note] InnoDB: Last binlog file './tipstrade04-bin.004023', position 29799719
2021-02-15 13:12:52 140611253319872 [Note] InnoDB: 128 out of 128 rollback segments are active.
2021-02-15 13:12:52 140611253319872 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2021-02-15 13:12:52 140611253319872 [Note] InnoDB: Creating shared tablespace for temporary tables
2021-02-15 13:12:52 140611253319872 [Note] InnoDB: Setting file '/var/lib/mysql/ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2021-02-15 13:12:52 140611253319872 [Note] InnoDB: File '/var/lib/mysql/ibtmp1' size is now 12 MB.
2021-02-15 13:12:52 140611253319872 [Note] InnoDB: 5.7.32 started; log sequence number 513506676885
2021-02-15 13:12:52 140591702722304 [Note] InnoDB: Loading buffer pool(s) from /home/mysql/ib_buffer_pool
2021-02-15 13:12:52 140611253319872 [Note] Plugin 'FEEDBACK' is disabled.
2021-02-15 13:12:52 140611253319872 [Note] Recovering after a crash using tipstrade04-bin
2021-02-15 13:12:52 140611253319872 [Note] Starting crash recovery...
2021-02-15 13:12:52 140611253319872 [Note] Crash recovery finished.
2021-02-15 13:12:52 140611253319872 [Note] Server socket created on IP: '::'.
2021-02-15 13:12:52 140611253319872 [Warning] 'proxies_priv' entry '@% root@tipstrade03' ignored in --skip-name-resolve mode.
2021-02-15 13:12:52 140611253319872 [ERROR] mysqld: Table './mysql/event' is marked as crashed and should be repaired
2021-02-15 13:12:52 140611253319872 [Warning] Checking table:   './mysql/event'
2021-02-15 13:12:52 140611253319872 [ERROR] mysql.event: 1 client is using or hasn't closed the table properly
2021-02-15 13:12:52 140611060475648 [Note] Event Scheduler: scheduler thread started with id 7
2021-02-15 13:12:52 140611253319872 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.2.36-MariaDB-10.2.36+maria~xenial-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
2021-02-15 13:12:55 140609785124608 [ERROR] mysqld: Table './asteriskcdrdb/cel' is marked as crashed and should be repaired
2021-02-15 13:12:55 140609785124608 [Warning] Checking table:   './asteriskcdrdb/cel'
2021-02-15 13:12:56 140609782699776 [ERROR] mysqld: Table './asteriskcdrdb/cdr' is marked as crashed and should be repaired
2021-02-15 13:12:56 140609782699776 [Warning] Checking table:   './asteriskcdrdb/cdr'
2021-02-15 13:13:03 140611059566336 [ERROR] mysqld: Table './tipstrade_2/tblTicketsOffers' is marked as crashed and should be repaired
2021-02-15 13:13:03 140611059566336 [Warning] Checking table:   './tipstrade_2/tblTicketsOffers'
2021-02-15 13:13:16 140591702722304 [Note] InnoDB: Buffer pool(s) load completed at 210215 13:13:16
2021-02-15 13:26:53 140591588833024 [ERROR] mysqld: Table './tipstrade_2/tblPrintQueue' is marked as crashed and should be repaired
2021-02-15 13:26:53 140591588833024 [Warning] Checking table:   './tipstrade_2/tblPrintQueue'

系统信息

输出自free

              total        used        free      shared  buff/cache   available
Mem:       65838544     9670572    11002756      170796    45165216    55299216
Swap:       7812092       19924     7792168

标签: ubuntumariadbsignalsmariadb-10.2

解决方案


我从来没有深究这一点。最后我咬紧牙关,从 10.2 -> 10.3 -> 10.4 -> 10.5 升级,确保我mysql_upgrade在每次更新之间运行(以及数据目录的完整备份mysql,这很方便!)。

从那时起,我一直在愉快地阅读、插入、更新和删除有问题的表中的数十万条记录,并且数据库没有跳过一个节拍。

我唯一的解释是:

  1. 警告“这可能是因为您遇到了错误。也可能是此二进制文件或其链接的库之一已损坏、构建不正确或配置错误。” 是正确的,升级服务器和依赖项解决了这个问题。
  2. 有表损坏,并mysql_upgrade解决了这个问题。

我已经排除了硬件错误,因为它又可以正常工作了。国际劳工组织也没有给我任何警告。


推荐阅读