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

Incorrect synchronisation on srv_running

    XMLWordPrintable

Details

    Description

      In innodb_init() there's wait for thd_destructor_thread startup:

                      mysql_thread_create(thd_destructor_thread_key,
                                          &thd_destructor_thread,
                                          NULL, thd_destructor_proxy, NULL);
                      while (!my_atomic_loadptr_explicit(reinterpret_cast<void**>
                                                         (&srv_running),
                                                         MY_MEMORY_ORDER_RELAXED))
                              os_thread_sleep(20);
      

      However if thd_destructor_thread dies before loadptr, this becomes dead loop. E.g. server shutdown during InnoDB initialisation?

      Second problem is in innobase_end(). In fact time to time I get crashes here.

                      st_my_thread_var* running = reinterpret_cast<st_my_thread_var*>(
                              my_atomic_loadptr_explicit(
                              reinterpret_cast<void**>(&srv_running),
                              MY_MEMORY_ORDER_RELAXED));
                      if (!abort_loop && running) {
                              // may be UNINSTALL PLUGIN statement
                              running->abort = 1;
                              mysql_cond_broadcast(running->current_cond);
                      }
      

      If thd_destructor_thread dies between atomic load and mysql_cond_broadcast(), it'll attempt to broadcast on destroyed cond via freed "running" pointer.

      The problem is much broader though. Background threads creation/destruction synchronisation is in sorry state. So we need to implement some universally applicable framework.

      Attachments

        Issue Links

          Activity

            People

              svoj Sergey Vojtovich
              svoj Sergey Vojtovich
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.