1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-6756: map a linux pid (child pid) to a connection id shown in the output of SHOW PROCESSLIST

Added tid (thread ID) for system where it is present.

 ps -eL -o tid,pid,command

shows the thread on Linux
This commit is contained in:
Oleksandr Byelkin
2015-08-12 23:09:48 +02:00
parent d9b25ae3db
commit 7dd137c4ac
14 changed files with 165 additions and 123 deletions

View File

@@ -69,6 +69,10 @@
#include "sql_connect.h"
#include "my_atomic.h"
#ifdef HAVE_SYS_SYSCALL_H
#include <sys/syscall.h>
#endif
/*
The following is used to initialise Table_ident with a internal
table name
@@ -867,6 +871,7 @@ THD::THD(bool is_wsrep_applier)
m_statement_psi(NULL),
m_idle_psi(NULL),
thread_id(0),
os_thread_id(0),
global_disable_checkpoint(0),
failed_com_change_user(0),
is_fatal_error(0),
@@ -2067,6 +2072,11 @@ bool THD::store_globals()
This allows us to move THD to different threads if needed.
*/
mysys_var->id= thread_id;
#ifdef __NR_gettid
os_thread_id= syscall(__NR_gettid);
#else
os_thread_id= 0;
#endif
real_id= pthread_self(); // For debugging
mysys_var->stack_ends_here= thread_stack + // for consistency, see libevent_thread_proc
STACK_DIRECTION * (long)my_thread_stack_size;