[MDEV-30260] Slave crashed:reload_acl_and_cache during shutdown Created: 2022-12-18  Updated: 2024-01-31

Status: Stalled
Project: MariaDB Server
Component/s: None
Affects Version/s: 10.5.16
Fix Version/s: 10.5

Type: Bug Priority: Major
Reporter: hejieming Assignee: Brandon Nesterenko
Resolution: Unresolved Votes: 1
Labels: None
Environment:

centos 7.6


Issue Links:
Blocks
is blocked by MDEV-32592 Backport MDEV-24660 to 10.4 Open
Relates
relates to MDEV-23034 10.5.4 mariadbd crashes during shutdown Closed

 Description   

Normal shutdown is triggered when the machine is powered off.

error log:

2022-12-05 20:15:52 0 [Note] /home/zright105/sql/bin/mysqld (initiated by: unknown): Normal shutdown
2022-12-05 20:15:52 0 [Note] Event Scheduler: Purging the queue. 0 events
2022-12-05 20:15:52 8 [Note] Error reading relay log event: slave SQL thread was killed
2022-12-05 20:15:52 8 [Note] Slave SQL thread exiting, replication stopped in log 'mysql-bin.000063' at position 385250448; GTID position '0-3630784761-1147213'
2022-12-05 20:15:52 8 [Note] master was 192.168.1.55:58306

Status information:

 Current dir: /data//zright105/data/
Running threads: 66  Cached threads: 0  Stack size: 299008
。。。
Events status:
LLA = Last Locked At  LUA = Last Unlocked At
WOC = Waiting On Condition  DL = Data Locked
The Event Scheduler is disabled

2022-12-05 20:15:52 7 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000063', position 385250448; GTID position 0-3630784761-1147213
2022-12-05 20:15:52 7 [Note] master was 192.168.1.55:58306
2022-12-05 20:15:52 0 [Warning] 'user' entry '@long-105-2' ignored in --skip-name-resolve mode.
2022-12-05 20:15:52 0 [Warning] 'proxies_priv' entry '@% root@long-105-2' ignored in --skip-name-resolve mode.
2022-12-05 20:15:52 1 [Note] Stopping ack receiver thread
2022-12-05 20:15:52 0 [Note] InnoDB: FTS optimize thread exiting.
221205 20:15:52 [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 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.5.16-MariaDB-log
key_buffer_size=16777216
read_buffer_size=262144
max_used_connections=4
max_threads=2002
thread_count=0
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 4676953 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x0
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...
2022-12-05 20:15:52 0 [Note] InnoDB: Starting shutdown...
2022-12-05 20:15:52 0 [Note] InnoDB: Dumping buffer pool(s) to /data/zright105/data/ib_buffer_pool
2022-12-05 20:15:52 0 [Note] InnoDB: Restricted to 32260 pages due to innodb_buf_pool_dump_pct=25
stack_bottom = 0x0 thread_stack 0x49000
2022-12-05 20:15:52 0 [Note] InnoDB: Buffer pool(s) dump completed at 221205 20:15:52
Printing to addr2line failed
/home/zright105/sql/bin/mysqld(my_print_stacktrace+0x2e)[0x557ee82aac1e]
/home/zright105/sql/bin/mysqld(handle_fatal_signal+0x485)[0x557ee7d05d05]
/usr/lib64/libpthread.so.0(+0x13280)[0x7f9b594d7280]
/home/zright105/sql/bin/mysqld(_Z22hostname_cache_refreshv+0x14)[0x557ee7d160d4]
/home/zright105/sql/bin/mysqld(_Z20reload_acl_and_cacheP3THDyP10TABLE_LISTPi+0x71d)[0x557ee7c1a07d]
/home/zright105/sql/bin/mysqld(signal_hand+0x23c)[0x557ee7a2924c]
/home/zright105/sql/bin/mysqld(+0xbd799b)[0x557ee7f8599b]
/usr/lib64/libpthread.so.0(+0x8f4b)[0x7f9b594ccf4b]
/usr/lib64/libc.so.6(clone+0x3f)[0x7f9b594047ef]
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...

core:

(gdb) info threads
  Id   Target Id         Frame 
  1    LWP 2357049       0x00007f9b594d3ff1 in pthread_kill () from /usr/lib64/libpthread.so.0
  2    LWP 2357037       0x00007f9b593ff169 in syscall () from /usr/lib64/libc.so.6
  3    LWP 2487017       0x00007f9b594d2df2 in pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
  4    LWP 2550697       0x00007f9b594d2df2 in pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
  5    LWP 2498812       0x00007f9b594d2df2 in pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
  6    LWP 2550698       0x00007f9b594d2df2 in pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
  7    LWP 2550699       0x00007f9b594d2df2 in pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
  8    LWP 2550700       0x00007f9b594d2df2 in pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
  9    LWP 2357036       0x00007f9b594d2df2 in pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
  10   LWP 2357035       0x00007f9b594d2df2 in pthread_cond_timedwait () from /usr/lib64/libpthread.so.0
  11   LWP 2357034       0x00007f9b593ff169 in syscall () from /usr/lib64/libc.so.6
(gdb) t 1
[Switching to thread 1 (LWP 2357049)]
#0  0x00007f9b594d3ff1 in pthread_kill () from /usr/lib64/libpthread.so.0
(gdb) bt
#0  0x00007f9b594d3ff1 in pthread_kill () from /usr/lib64/libpthread.so.0
#1  0x0000557ee82aaa19 in my_write_core (sig=<optimized out>) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/mysys/stacktrace.c:424
#2  0x0000557ee7d05d20 in handle_fatal_signal (sig=11) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/signal_handler.cc:344
#3  <signal handler called>
#4  hash_filo::clear (locked=false, this=0x0) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/hash_filo.h:87
#5  hostname_cache_refresh () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/hostname.cc:135
#6  0x0000557ee7c1a07d in reload_acl_and_cache (thd=thd@entry=0x0, options=2147499823, options@entry=2147483695, tables=tables@entry=0x0, 
    write_to_binlog=write_to_binlog@entry=0x7f9b4a4bcdc0) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/sql_reload.cc:352
#7  0x0000557ee7a2924c in signal_hand (arg=arg@entry=0x0) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/mysqld.cc:3055
#8  0x0000557ee7f8599b in pfs_spawn_thread (arg=0x557eecbfdc68) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/perfschema/pfs.cc:2201
#9  0x00007f9b594ccf4b in ?? () from /usr/lib64/libpthread.so.0
#10 0x00007f9b594047ef in clone () from /usr/lib64/libc.so.6
(gdb) t 11
[Switching to thread 11 (LWP 2357034)]
#0  0x00007f9b593ff169 in syscall () from /usr/lib64/libc.so.6
(gdb) bt
#0  0x00007f9b593ff169 in syscall () from /usr/lib64/libc.so.6
#1  0x00007f9b59feb221 in io_submit () from /usr/lib64/libaio.so.1
#2  0x0000557ee824230b in tpool::aio_linux::submit_io (this=<optimized out>, cb=<optimized out>)
    at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/tpool/aio_linux.cc:168
#3  0x0000557ee80812d3 in tpool::thread_pool::submit_io (cb=0x557eea688170, this=<optimized out>) at /opt/hw/gcc-10.3/include/c++/10/bits/unique_ptr.h:421
#4  os_aio (type=..., buf=0x7f9b385fc000, offset=28622848, n=16384) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/os/os0file.cc:3877
#5  0x0000557ee81ca1a0 in fil_space_t::io (this=this@entry=0x557eecb82668, type=..., offset=<optimized out>, len=<optimized out>, buf=<optimized out>, 
    bpage=bpage@entry=0x7f9b34110000) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/include/os0file.h:209
#6  0x0000557ee818abc5 in buf_flush_page (bpage=0x7f9b34110000, lru=lru@entry=false, space=space@entry=0x557eecb82668)
    at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/include/os0file.h:212
#7  0x0000557ee818c0e7 in buf_do_flush_list_batch (lsn=18446744073709551615, max_n=24000)
    at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/buf/buf0flu.cc:1515
#8  buf_flush_list (lsn=18446744073709551615, max_n=24000) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/buf/buf0flu.cc:1591
#9  buf_flush_list (max_n=24000, lsn=18446744073709551615) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/buf/buf0flu.cc:1571
#10 0x0000557ee79e1fc2 in buf_flush_buffer_pool () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/buf/buf0flu.cc:2507
#11 0x0000557ee79af907 in logs_empty_and_mark_files_at_shutdown () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/log/log0log.cc:1149
#12 0x0000557ee79cc4d2 in innodb_shutdown () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/srv/srv0start.cc:2026
#13 0x0000557ee7fffc6f in innobase_end () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/handler/ha_innodb.cc:4152
#14 innobase_end () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/storage/innobase/handler/ha_innodb.cc:4139
#15 0x0000557ee7d08300 in ha_finalize_handlerton (plugin=0x557eea385060) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/handler.cc:583
#16 0x0000557ee7b02709 in plugin_deinitialize (plugin=0x557eea385060, ref_check=ref_check@entry=true)
    at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/sql_plugin.cc:1264
#17 0x0000557ee7b0654e in reap_plugins () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/sql_plugin.cc:1340
#18 0x0000557ee7b07115 in plugin_shutdown () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/sql_plugin.cc:2047
#19 0x0000557ee7a28024 in clean_up (print_message=true) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/mysqld.cc:1995
#20 clean_up (print_message=<optimized out>) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/mysqld.cc:1957
#21 0x0000557ee7a32b27 in mysqld_main (argc=<optimized out>, argv=<optimized out>) at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/mysqld.cc:5751
#22 0x00007f9b59331c57 in __libc_start_main () from /usr/lib64/libc.so.6
#23 0x0000557ee7a268ee in _start () at /data/fuxi_ci_workspace/6357e590f2f6990b8bd018b0/sql/mysqld.cc:4388



 Comments   
Comment by hejieming [ 2022-12-18 ]

Memory corruption occurred.
in thread 1, the function named hostname_cache_refresh calls hostname_cache which has been released by hostname_cache_free in clean_up in thread 11,

Comment by Brandon Nesterenko [ 2023-10-23 ]

Hi Elkin!

This is ready for review: PR-2798

Comment by Andrei Elkin [ 2024-01-20 ]

Reviewed the latest gh patch to approve.

Comment by Brandon Nesterenko [ 2024-01-31 ]

Moved to stalled because there was an occasional test failure that needs to be debugged before pushing, because it shows that the server can still hang on shutdown, where THD_count is shown to be 1 while there are only system threads alive. So it seems a thread somewhere is not correctly cleaning up after itself, leaving close_connections() to wait indefinitely waiting for the count to be 0.

Generated at Thu Feb 08 10:14:54 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.