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

Backport Threadpool improvements from Percona Server

    XMLWordPrintable

    Details

      Description

      Threadpool implementation on Percona server is based on the Maria one but some improvements has been made such as the priority queue throttling (http://www.percona.com/doc/percona-server/5.5/performance/threadpool.html#low-priority-queue-throttling) :

      One case that can limit thread pool performance and even lead to deadlocks under high concurrency is a situation when thread groups are oversubscribed due to active threads reaching the oversubscribe limit, but all/most worker threads are actually waiting on locks currently held by a transaction from another connection that is not currently in the thread pool.

      What happens in this case is that those threads in the pool that have marked themselves inactive are not accounted to the oversubscribe limit. As a result, the number of threads (both active and waiting) in the pool grows until it hits thread_pool_max_threads value. If the connection executing the transaction which is holding the lock has managed to enter the thread pool by then, we get a large (depending on the thread_pool_max_threads value) number of concurrently running threads, and thus, suboptimal performance as a result. Otherwise, we get a deadlock as no more threads can be created to process those transaction(s) and release the lock(s).

      Such situations are prevented by throttling the low priority queue when the total number of worker threads (both active and waiting ones) reaches the oversubscribe limit. That is, if there are too many worker threads, do not start new transactions and create new threads until queued events from the already started transactions are processed.

      Another change that has been made is that the default value for the variable thread_pool_max_threads has been bumped :

      Default value for thread_pool_max_threads was changed from 500 to 100 000. This change was introduced because limiting the total number of threads in the Thread Pool can result in deadlocks and uneven distribution of worker threads between thread groups in case of stalled connections.

      The default value of 500 is pretty restrictive and can be limitating on some setups, an higher value might be better suited for default to avoid hitting the threads limit long before hitting the max_connections limit.

        Attachments

          Activity

            People

            Assignee:
            serg Sergei Golubchik
            Reporter:
            jb-boin Jean Weisbuch
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Dates

              Due:
              Created:
              Updated:
              Resolved: