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

LP:643463 - slow XtraDB shutdown due to 10 second sleep in purge thread

    Details

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

      Description

      Shutting down XtraDB can take up to 10 seconds, even when there is no actual
      work to do during shutdown.

      An easy way to see this is to run a quick innodb test in the mysql-test-run.pl
      test suite:

      ./mtr innodb-consistent

      This takes >10 seconds, even though the actual test runs instantaneous.

      The problem is this code in srv/srv0srv.c:

      srv_purge_thread(...)
      {
      ulint sleep_ms= 10000; /* initial: 10 sec. */
      ...

      loop:
      if (srv_shutdown_state > 0)

      { ... }

      os_thread_sleep( sleep_ms * 1000 );
      ...
      goto loop;

      So right after startup, the purge thread sleeps for 10 seconds, so server
      cannot shut down for at least 10 seconds after startup.

      Of course, in a production server, the purge thread sleep could have adjusted
      itself to less than 10 seconds, and a busy server anyway will probably need
      much more than 10 seconds to shut down cleanly.

      But for development and testing, it is annoying to have to wait for 10 seconds
      for shutdown.

      Suggested fix:

      Change the os_thread_sleep() into a sleep that can be interrupted by
      shutdown. For example a wait with os_event_wait_time() on an event created
      specifically for this. (Note that currently os_event_wait_time() waits
      infinitely on non-windows, but it looks easy to fix this using
      pthread_cond_timedwait()). Then signal the purge thread sleep to wakeup early
      during server shutdown.

        Gliffy Diagrams

          Attachments

            Activity

            Hide
            knielsen Kristian Nielsen added a comment -

            I used PMP to find some more sleeps in the XtraDB shutdown code. This additional
            patch, which goes on top of the one attached before, fixes the remaining cases.

            With this, server shutdown during mtr tests is very close to --innodb-fast-shutdown-2.
            Additional patch fixing more sleeps during shutdown
            LPexportBug643463_mbug643463.patch

            Show
            knielsen Kristian Nielsen added a comment - I used PMP to find some more sleeps in the XtraDB shutdown code. This additional patch, which goes on top of the one attached before, fixes the remaining cases. With this, server shutdown during mtr tests is very close to --innodb-fast-shutdown-2. Additional patch fixing more sleeps during shutdown LPexportBug643463_mbug643463.patch
            Hide
            knielsen Kristian Nielsen added a comment -

            Re: slow XtraDB shutdown due to 10 second sleep in purge thread
            I used PMP to find some more sleeps in the XtraDB shutdown code. This additional
            patch, which goes on top of the one attached before, fixes the remaining cases.

            With this, server shutdown during mtr tests is very close to --innodb-fast-shutdown-2.

            Show
            knielsen Kristian Nielsen added a comment - Re: slow XtraDB shutdown due to 10 second sleep in purge thread I used PMP to find some more sleeps in the XtraDB shutdown code. This additional patch, which goes on top of the one attached before, fixes the remaining cases. With this, server shutdown during mtr tests is very close to --innodb-fast-shutdown-2.
            Hide
            knielsen Kristian Nielsen added a comment -

            Attaching BSD copyright license for the patches submitted to this bug report.
            BSD copyright license for attached patches
            LPexportBug643463_COPYING.innodb_fast_shutdown

            Show
            knielsen Kristian Nielsen added a comment - Attaching BSD copyright license for the patches submitted to this bug report. BSD copyright license for attached patches LPexportBug643463_COPYING.innodb_fast_shutdown
            Hide
            knielsen Kristian Nielsen added a comment -

            Re: slow XtraDB shutdown due to 10 second sleep in purge thread
            Attaching BSD copyright license for the patches submitted to this bug report.

            Show
            knielsen Kristian Nielsen added a comment - Re: slow XtraDB shutdown due to 10 second sleep in purge thread Attaching BSD copyright license for the patches submitted to this bug report.
            Hide
            ratzpo Rasmus Johansson added a comment -

            Launchpad bug id: 643463

            Show
            ratzpo Rasmus Johansson added a comment - Launchpad bug id: 643463

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: