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

Threadpool/Unix- wait_begin() function does not wake/create threads, when it should

    XMLWordPrintable

Details

    Description

      There is a bug in wait notification function that greately reduces its usefulness.
      It is present in all versions from 5.5 to 10.5

      Let's look at the condition under which threads are woken or created

      https://github.com/MariaDB/server/blob/17b4f99928eb222dcc7c7b0404ccbcd1063af026/sql/threadpool_unix.cc#L1175

      threadpool_unix.cc, line 1175ff

        if ((thread_group->active_thread_count == 0) && 
           (thread_group->queue.is_empty() || !thread_group->listener))
        {
      ...
          wake_or_create_thread(thread_group);
        }
      

      thread_group->queue.is_empty() means empty request queue, or that there is no work to do. So wakeup/create thread is done if there is no work to do, but not if there is some work to do.

      It should actually be !thread_group->queue.is_empty() in that condition.

      Historical note : this condition was initially implemented correctly, until commit 18c9b345b43b62b7c4dbac8ce0289c1c8103c2d1 (Threadpool -address review comments) removed the negation.

      See
      https://github.com/MariaDB/server/commit/18c9b345b43b62b7c4dbac8ce0289c1c8103c2d1#diff-efffe15be841d5d0bab2a9c92e3e9555L976

      Attachments

        Activity

          People

            wlad Vladislav Vaintroub
            wlad Vladislav Vaintroub
            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.