There is feature that is there in Percona tree 5.5+ and also in MySQL/Enterprise
but not in MariaDB is priorization
- By default, connection that is in transaction gets a priority boost (which translated to
in transaction= low prio, outside of transaction => high prio). The first statement after "begin" does not need to be high prio (this transaction does not actually use any resources)
- We need to have a variable that will allow to specify per-connection or global scheduling behavior (auto = based on transaction status, high - always high prio, low- always low prio)
This way, it would be easy to return back to FIFO scheduling if someone prefers that (i.e set global threadpool_priority=high). Or for a connection to be "nice" (setting priority = low regardless of transaction status), if it does not unimportant work . This variable is akin to Percona's threadpool_high_prio_mode=[transactions|statements|none] , but with an understandable name.
- On Unix ,we'll use separate queues for high priority and low priority items. high priority queue is checked before low prio when an event is dequeued.
- On Windows threadpool, it is possible to 'yield' low prio work items.
- On Unix, to avoid starvation of the low prio items, periodically the old items in low prio queue need to be merged at the end of high prio queue. We can use 'thread_pool_kickup_timer' logic, like MySQL Enterprise is doing it.
- We won't be using 'throttling of low prio queue' like Percona, as restricting the number of active+waiting threads can easily lead to a deadlock (single global lock or table lock would suffice to check that)