Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-18353

Shutdown may miss to wait for connection thread

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5, 10.6
    • Fix Version/s: 10.4.21, 10.5.12, 10.6.4
    • Component/s: Server
    • Labels:
      None

      Description

      Side effects may vary, but I guess crash is most probable outcome.

      To reproduce, first apply this patch:

      diff --git a/sql/mysqld.cc b/sql/mysqld.cc
      index e1c9f68..028db04 100644
      --- a/sql/mysqld.cc
      +++ b/sql/mysqld.cc
      @@ -2045,11 +2045,13 @@ static void mysqld_exit(int exit_code)
       #ifdef SAFEMALLOC
           sf_report_leaked_memory(0);
       #endif
      -    DBUG_SLOW_ASSERT(global_status_var.global_memory_used == 0);
      +//    DBUG_SLOW_ASSERT(global_status_var.global_memory_used == 0);
         }
         cleanup_tls();
         DBUG_LEAVE;
         sd_notify(0, "STATUS=MariaDB server is down");
      +  if (delayed_queue_size == 10)
      +    sleep(10);
         exit(exit_code); /* purecov: inspected */
       }
       
      diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc
      index a2f2407..373f9c6 100644
      --- a/sql/sql_connect.cc
      +++ b/sql/sql_connect.cc
      @@ -1303,6 +1303,9 @@ pthread_handler_t handle_one_connection(void *arg)
       {
         CONNECT *connect= (CONNECT*) arg;
       
      +  if (delayed_queue_size == 10)
      +    sleep(10);
      +
         mysql_thread_set_psi_id(connect->thread_id);
       
         do_handle_one_connection(connect);
      

      Note: delayed_queue_size variable was chosen randomly and doesn't make any difference, it is there just to avoid sleeping in unrelated connections.

      Test:

      set global delayed_queue_size=10;
      connect(con1,localhost,root,,);
      

      run mtr and as soon as it shows "set global delayed_queue_size=10;" kill mysqld manually, like killall mysqld.

      You should end up with crash like like:

      Thread 2 (Thread 0x7fb03f8678c0 (LWP 16008)):
      #0  0x00007fb03d2da30d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
      #1  0x00007fb03d2da25a in __sleep (seconds=0) at ../sysdeps/posix/sleep.c:55
      #2  0x0000559aa846aa4d in mysqld_exit (exit_code=0) at /home/svoj/devel/maria/mariadb/sql/mysqld.cc:2054
      #3  0x0000559aa847308f in mysqld_main (argc=155, argv=0x559aaabc1a20) at /home/svoj/devel/maria/mariadb/sql/mysqld.cc:6034
      #4  0x0000559aa8466ee0 in main (argc=32, argv=0x7ffc504365a8) at /home/svoj/devel/maria/mariadb/sql/main.cc:25
       
      Thread 1 (Thread 0x7fb0354c8700 (LWP 16040)):
      #0  __pthread_kill (threadid=<optimized out>, signo=11) at ../sysdeps/unix/sysv/linux/pthread_kill.c:62
      #1  0x0000559aa9071112 in my_write_core (sig=11) at /home/svoj/devel/maria/mariadb/mysys/stacktrace.c:481
      #2  0x0000559aa88a92f1 in handle_fatal_signal (sig=11) at /home/svoj/devel/maria/mariadb/sql/signal_handler.cc:305
      #3  <signal handler called>
      #4  0x0000559aa8ae5813 in set_thread_id_v1 (thread=0x7fb03a8be340, processlist_id=10) at /home/svoj/devel/maria/mariadb/storage/perfschema/pfs.cc:1945
      #5  0x0000559aa86fa923 in inline_mysql_thread_set_psi_id (id=10) at /home/svoj/devel/maria/mariadb/include/mysql/psi/mysql_thread.h:1275
      #6  0x0000559aa86fdb1d in handle_one_connection (arg=0x559aab131c90) at /home/svoj/devel/maria/mariadb/sql/sql_connect.cc:1309
      #7  0x0000559aa8ae55d0 in pfs_spawn_thread (arg=0x559aab0acd30) at /home/svoj/devel/maria/mariadb/storage/perfschema/pfs.cc:1862
      #8  0x00007fb03de806ba in start_thread (arg=0x7fb0354c8700) at pthread_create.c:333
      #9  0x00007fb03d31541d in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:109
      

      Most probably regression after connection speed improvements. And likely affects 10.0+.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              serg Sergei Golubchik
              Reporter:
              svoj Sergey Vojtovich
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration