Description:
When the thread pool plugin the user name in the sys.processlist and sys.session views will just show the thread name (thread_pool/tp_one_connection) instead of the actual user name.
How to repeat:
---------------------------
Without thread pool plugin:
---------------------------
mysql> SELECT * FROM sys.session\G
*************************** 1. row ***************************
thd_id: 27
conn_id: 4
user: root@localhost
db: NULL
command: Query
state: Sending data
time: 0
current_statement: SELECT * FROM sys.session
statement_latency: 16.63 ms
progress: NULL
lock_latency: 15.17 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 4
tmp_disk_tables: 1
full_scan: YES
last_statement: NULL
last_statement_latency: NULL
current_memory: 3.08 MiB
last_wait: NULL
last_wait_latency: NULL
source: NULL
trx_latency: 1.52 ms
trx_state: ACTIVE
trx_autocommit: YES
pid: 9866
program_name: mysql
...
------------------------
With thread pool plugin:
------------------------
From my.cnf:
[mysqld]
plugin-load = thread_pool.so
mysql> mysql> SELECT * FROM sys.session\G
*************************** 1. row ***************************
thd_id: 44
conn_id: 4
user: thread_pool/tp_one_connection
db: NULL
command: Query
state: Sending data
time: 0
current_statement: SELECT * FROM sys.session
statement_latency: 101.34 ms
progress: NULL
lock_latency: 99.16 ms
rows_examined: 0
rows_sent: 0
rows_affected: 0
tmp_tables: 4
tmp_disk_tables: 1
full_scan: YES
last_statement: NULL
last_statement_latency: NULL
current_memory: 3.06 MiB
last_wait: NULL
last_wait_latency: NULL
source: NULL
trx_latency: 2.30 ms
trx_state: ACTIVE
trx_autocommit: YES
pid: 9866
program_name: mysql
...
mysql> SELECT * FROM performance_schema.threads WHERE THREAD_ID = 44\G
*************************** 1. row ***************************
THREAD_ID: 44
NAME: thread/thread_pool/tp_one_connection
TYPE: FOREGROUND
PROCESSLIST_ID: 4
PROCESSLIST_USER: root
PROCESSLIST_HOST: localhost
PROCESSLIST_DB: sys
PROCESSLIST_COMMAND: Query
PROCESSLIST_TIME: 0
PROCESSLIST_STATE: Sending data
PROCESSLIST_INFO: SELECT * FROM performance_schema.threads WHERE THREAD_ID = 44
PARENT_THREAD_ID: NULL
ROLE: NULL
INSTRUMENTED: YES
HISTORY: YES
CONNECTION_TYPE: SSL/TLS
THREAD_OS_ID: NULL
1 row in set (0.00 sec)
Suggested fix:
Currently the check whether to display a user name or the thread name is:
IF(pps.name = 'thread/sql/one_connection',
CONCAT(pps.processlist_user, '@', pps.processlist_host),
REPLACE(pps.name, 'thread/', '')) user,
So only when the one connection per thread method is used for thread handling, the user name and host name will be picked up from the performance_schema.threads table. This should be extended to include thread/thread_pool/tp_one_connection .