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

[PATCH] MariaDB hangs if terminated quickly after start

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.0.10
    • Fix Version/s: 10.0.11
    • Component/s: None
    • Labels:
      None

      Description

      If MariaDB receives SIGTERM after the call to start_signal_handler() but before the call to init_slave() then kill_server_thread() will call close_connections() (through kill_server() ) which will ask all threads to terminate and will start to wait on COND_thread_count. After that init_slave() will be called, it will call run_slave_init_thread(), which will launch handle_slave_init() and will start to wait on COND_thread_count too. At this point if handle_slave_init() calls mysql_cond_signal(&COND_thread_count) then it can wake up close_connections() which will do nothing and return back to sleep. But run_slave_init_thread() will remain sleeping and no one will ever wake it up, MariaDB will hang forever with "kill -9" as the only chance to exit.

      So the call to mysql_cond_signal(&COND_thread_count) in the handle_slave_init() should be changed to mysql_cond_broadcast(&COND_thread_count).

      Note that calling *_broadcast instead of *_signal matches all other usages of COND_thread_count throughout MariaDB code.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            pivanof Pavel Ivanov added a comment -

            The call to mysql_cond_signal that needs to be changed is at slave.cc:321 now.

            Show
            pivanof Pavel Ivanov added a comment - The call to mysql_cond_signal that needs to be changed is at slave.cc:321 now.
            Hide
            knielsen Kristian Nielsen added a comment -

            Nice find, thanks Pavel!

            Pushed to 10.0

            Show
            knielsen Kristian Nielsen added a comment - Nice find, thanks Pavel! Pushed to 10.0

              People

              • Assignee:
                knielsen Kristian Nielsen
                Reporter:
                pivanof Pavel Ivanov
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: