1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-14505 - Threads_running becomes scalability bottleneck

Instead of updating global counter, calculate Threads_running on the fly.
All threads having command != COM_SLEEP are included.

Behaviour changes:

Previously SHOW STATUS and SHOW GLOBAL STATUS returned the same values
representing global status. Now SHOW STATUS always returns 1 indicating that
current session has 1 thread running.

Previously only threads that were executing dispatch_command() or running events
were accounted by Threads_running. Now it is rough equivalent of
SELECT COUNT(*) FROM INFORMATION_SCHEMA.PROCESSLIST WHERE state!='Sleep'
This commit is contained in:
Sergey Vojtovich
2017-12-12 22:53:38 +04:00
parent 751e0f6b1e
commit 159a6c2e60
10 changed files with 44 additions and 23 deletions

View File

@ -4207,6 +4207,12 @@ void THD::set_status_var_init()
{
bzero((char*) &status_var, offsetof(STATUS_VAR,
last_cleared_system_status_var));
/*
Session status for Threads_running is always 1. It can only be queried
by thread itself via INFORMATION_SCHEMA.SESSION_STATUS or SHOW [SESSION]
STATUS. And at this point thread is guaranteed to be running.
*/
status_var.threads_running= 1;
}