简单记录
如下线面3种ID到底什么意思,这个问题我一直没去看:
(root@localhost)[05:47:31] [performance_schema ;]> select THREAD_ID,PROCESSLIST_ID,THREAD_OS_ID from performance_schema.threads ;
+-----------+----------------+--------------+
| THREAD_ID | PROCESSLIST_ID | THREAD_OS_ID |
+-----------+----------------+--------------+
| 1 | NULL | 17721 |
| 2 | NULL | 17728 |
| 3 | NULL | 17729 |
| 4 | NULL | 17730 |
| 5 | NULL | 17731 |
| 6 | NULL | 17732 |
| 7 | NULL | 17733 |
| 8 | NULL | 17734 |
| 9 | NULL | 17735 |
| 10 | NULL | 17736 |
| 11 | NULL | 17737 |
| 12 | NULL | 17738 |
| 13 | NULL | 17739 |
| 15 | NULL | 17743 |
| 16 | NULL | 17744 |
| 17 | NULL | 17745 |
| 18 | NULL | 17746 |
| 19 | NULL | 17747 |
| 20 | NULL | 17749 |
| 21 | NULL | 17748 |
| 22 | NULL | 17750 |
| 23 | NULL | 17751 |
| 24 | NULL | 17752 |
| 25 | NULL | 17763 |
| 26 | 1 | 17764 |
| 27 | 2 | 17969 |
| 44 | 19 | 31424 |
+-----------+----------------+--------------+
- THREAD_ID:performance_schema里面的一个计数器如下:
PFS_thread* create_thread(PFS_thread_class *klass, const void *identity,
ulonglong processlist_id)
{
PFS_thread *pfs;
pfs_dirty_state dirty_state;
pfs= global_thread_container.allocate(& dirty_state);
if (pfs != NULL)
{
pfs->m_thread_internal_id=
PFS_atomic::add_u64(&thread_internal_id_counter.m_u64, 1);
pfs->m_parent_thread_internal_id= 0;
pfs->m_processlist_id= static_cast<ulong>(processlist_id);
作者微信:gaopp_22389860
thread_internal_id_counter计数器一直增加。可以看到这是performance_schema内部使用的。
- PROCESSLIST_ID
是传入参数processlist_id,也就是我们平时show processlist出来的。一般MySQL层使用它。
- THREAD_OS_ID
OS级别的线程ID,来自函数
pfs->m_thread_os_id= my_thread_os_id();
记录于此 以备后用。
作者微信:gaopp_22389860