Bug #100602 mysql server crashed when initialized
Submitted: 21 Aug 2020 13:00 Modified: 21 Aug 2020 13:07
Reporter: Cheng Zhou Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:8.0.18 OS:Any
Assigned to: CPU Architecture:Any

[21 Aug 2020 13:00] Cheng Zhou
Description:
After fixed the problem reported in: https://bugs.mysql.com/bug.php?id=100601 as the suggested suggested fix, compiled a debug version without some particular types of Performance Schema instrumentation.
mysql server crashed when initialized.

error log:
2020-08-21T20:23:48.695036+08:00 5 [Note] [MY-010456] [Server] Bootstrapping complete
2020-08-21T20:23:48.699723+08:00 0 [Note] [MY-010067] [Server] Giving 0 client threads a chance to die gracefully
2020-08-21T20:23:48.699876+08:00 0 [Note] [MY-010117] [Server] Shutting down slave threads
2020-08-21T20:23:48.699948+08:00 0 [Note] [MY-010118] [Server] Forcefully disconnecting 0 remaining clients
2020-08-21T20:23:48.701825+08:00 0 [Note] [MY-012330] [InnoDB] FTS optimize thread exiting.
2020-08-21T20:23:48.738632+08:00 0 [Note] [MY-013072] [InnoDB] Starting shutdown...
2020-08-21T20:23:48.956871+08:00 0 [Note] [MY-013084] [InnoDB] Log background threads are being closed...
12:23:49 UTC - mysqld got signal 6 ;
Most likely, you have hit a bug, but this error can also be caused by malfunctioning hardware.
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...
stack_bottom = 0 thread_stack 0x46000
/home/xxx/bin/mysqld(my_print_stacktrace(unsigned char const*, unsigned long)+0x43) [0x4b90fa3]
/home/xxx/bin/mysqld(handle_fatal_signal+0x2bf) [0x382fb30]
/lib64/libpthread.so.0(+0xf5e0) [0x7fc8cae9e5e0]
/lib64/libc.so.6(gsignal+0x37) [0x7fc8c90971f7]
/lib64/libc.so.6(abort+0x148) [0x7fc8c90988e8]
/lib64/libc.so.6(+0x74f47) [0x7fc8c90d6f47]
/lib64/libc.so.6(+0x7c619) [0x7fc8c90de619]
/home/xxx/bin/mysqld(srv_free()+0x1f9) [0x4f0696a]
/home/xxx/bin/mysqld(srv_shutdown()+0x569) [0x4f1a919]
/home/xxx/bin/mysqld() [0x4c7a714]
/home/xxx/bin/mysqld(ha_finalize_handlerton(st_plugin_int*)+0xc2) [0x39da128]
/home/xxx/bin/mysqld() [0x3683820]
/home/xxx/bin/mysqld() [0x3683ed5]
/home/xxx/bin/mysqld(plugin_shutdown()+0xba) [0x3686c73]
/home/xxx/bin/mysqld() [0x34b8258]
/home/xxx/bin/mysqld() [0x34b7bfe]
/home/xxx/bin/mysqld() [0x34c8a28]
/home/xxx/bin/mysqld(mysqld_main(int, char**)+0x2c17) [0x34c7c69]
/home/xxx/bin/mysqld(main+0x20) [0x34b5906]
/lib64/libc.so.6(__libc_start_main+0xf5) [0x7fc8c9083c05]
/home/xxx/bin/mysqld() [0x34b5819]

How to repeat:
1. Fix the bug reported in: https://bugs.mysql.com/bug.php?id=100601 as the suggested fix.

2.  Compiled with the CMake options including the following:
            -DDISABLE_PSI_COND=1 \
            -DDISABLE_PSI_DATA_LOCK=1 \
            -DDISABLE_PSI_ERROR=1 \
            -DDISABLE_PSI_FILE=1 \
            -DDISABLE_PSI_IDLE=1 \
            -DDISABLE_PSI_MEMORY=1 \
            -DDISABLE_PSI_METADATA=1 \
            -DDISABLE_PSI_MUTEX=1 \
            -DDISABLE_PSI_PS=1 \
            -DDISABLE_PSI_RWLOCK=1 \
            -DDISABLE_PSI_SOCKET=1 \
            -DDISABLE_PSI_SP=1 \
            -DDISABLE_PSI_STAGE=1 \
            -DDISABLE_PSI_STATEMENT=1 \
            -DDISABLE_PSI_STATEMENT_DIGEST=1 \
            -DDISABLE_PSI_TABLE=1 \
            -DDISABLE_PSI_THREAD=1 \
            -DDISABLE_PSI_TRANSACTION=1 \
            -DWITH_DEBUG=1 

3. make and make install;
4. initialize the mysql server:
~/bin/mysqld --defaults-file=/home/xxx/etc/my.cnf --initialize-insecure --user=xxx

Suggested fix:
1. mysql.8.0.18/storage/innobase/include/srv0srv.h:

--- a/storage/innobase/include/srv0srv.h
+++ b/storage/innobase/include/srv0srv.h
@@ -220,7 +220,7 @@ struct Srv_threads {

   /** Page cleaner workers. Note that m_page_cleaner_workers[0] is the
   same shared state as m_page_cleaner_coordinator. */
-  IB_thread *m_page_cleaner_workers;
+  IB_thread *m_page_cleaner_workers{nullptr};

2. mysql-8.0.18/storage/innobase/srv/srv0srv.cc:

--- a/storage/innobase/srv/srv0srv.cc
+++ b/storage/innobase/srv/srv0srv.cc
@@ -1208,7 +1208,11 @@ void srv_free(void) {
     for (size_t i = 0; i < srv_threads.m_page_cleaner_workers_n; ++i) {
       srv_threads.m_page_cleaner_workers[i] = {};
     }
+#ifdef UNIV_PFS_MEMORY
     ut_free(srv_threads.m_page_cleaner_workers);
+#else
+    UT_DELETE_ARRAY(srv_threads.m_page_cleaner_workers);
+#endif
     srv_threads.m_page_cleaner_workers = nullptr;
   }

@@ -1216,7 +1220,11 @@ void srv_free(void) {
     for (size_t i = 0; i < srv_threads.m_purge_workers_n; ++i) {
       srv_threads.m_purge_workers[i] = {};
     }
+#ifdef UNIV_PFS_MEMORY
     ut_free(srv_threads.m_purge_workers);
+#else
+    UT_DELETE_ARRAY(srv_threads.m_purge_workers);
+#endif
     srv_threads.m_purge_workers = nullptr;
   }
[21 Aug 2020 13:07] MySQL Verification Team
HI Mr. Zhou,

Thank you for your bug report.

However, this report is considered as a continuation of your problems with excluding necessary PSI keys, as reported in the bug #100601.

Hence, this bug is a duplicate of the bug #100601.