16. SEMAPHORES
1. Semaphores .进程间相互通信,避免多个进程共享资源时发生冲突。(起并发控制作用)
几个字段:
Mutex spin waits :一个线程获取mutex,但mutex不可用(没获取到),线程在一个spin wait 执行check的次数。
Rounds:线程在spin-wait cycle中 ,执行check mutex的总数。
Rw-share 共享锁,RW-excl 排他锁(exclusive)。
OS waits:线程放弃spin waiting,进行sleep的总数。
signal count 22133482=OS waits 13850218+ OS waits 8365537+ OS waits 327946
1.大量的thread等待信号量原因是: 磁盘io读写问题,innodb 内部的 上下文切换导致。
16
17. SEMAPHORES
----------
SEMAPHORES
----------
OS WAIT ARRAY INFO: reservation count 13569, signal count 11421
--Thread 1152170336 has waited at ./../include/buf0buf.ic line 630 for 0.00 seconds the semaphore:
Mutex at 0x2a957858b8 created file buf0buf.c line 517, lock var 0
waiters flag 0
wait is ending
--Thread 1147709792 has waited at ./../include/buf0buf.ic line 630 for 0.00 seconds the semaphore:
Mutex at 0x2a957858b8 created file buf0buf.c line 517, lock var 0
waiters flag 0
wait is ending
Mutex spin waits 5672442, rounds 3899888, OS waits 4719
RW-shared spins 5920, OS waits 2918; RW-excl spins 3463, OS waits 3163
几个字段:
Lock var 0, mutex状态标志,locked=1,free=0。
Waiters flag 0, 当前waiter的编号。
Wait is ending,waiter状态。
表示,当前的mutex是free状态,等待该mutex的线程的等待状态 为0,都在等待该mutex.但该mutex已经是
free,只不过调度器还没有让线程处于运行状态。线程等待调度器运行。
1.大量的thread等待信号量原因是: 磁盘io读写问题,innodb 内部的 上下文切换导致。
17
18. SEMAPHORES
Kernel_mutex 的例子:
----------
--Thread 140370743510784 has waited at trx0trx.c line 1184 for 0.0000 seconds the semaphore:
Mutex at 0x2b0ccc8 '&kernel_mutex', lock var 1
waiters flag 0
--Thread 140370752542464 has waited at trx0trx.c line 1772 for 0.0000 seconds the semaphore:
Mutex at 0x2b0ccc8 '&kernel_mutex', lock var 1
waiters flag 0
--Thread 140088222295808 has waited at trx0trx.c line 1184 for 0.0000 seconds the semaphore:
Mutex at 0x2b0ccc8 '&kernel_mutex', lock var 1
waiters flag 0
几个字段:
Lock var 0, mutex状态标志,locked=1,free=0。
Waiters flag 0, 当前waiter的编号。
Wait is ending,waiter状态。
表示,当前的kernel_mutex是lock状态,等待该mutex的线程的等待状态 为0,都在等待该mutex.
1.大量的thread等待信号量原因是: 磁盘io读写问题,innodb 内部的 上下文切换导致。
18
25. TRANSACTIONS
------------
TRANSACTIONS
------------
Trx id counter 0 3638031820
Purge done for trx's n:o < 0 3637930396 undo n:o < 0 0
History list length 19988
Total number of lock structs in row lock hash table 0
LIST OF TRANSACTIONS FOR EACH SESSION:
---TRANSACTION 0 0, not started, process no 20150, OS thread id 1162877280
MySQL thread id 119512286, query id 46504256930 localhost root
show engine innodb status
---TRANSACTION 0 3638031818, not started, process no 20150, OS thread id 1196996960
MySQL thread id 119512319, query id 46504256929 10.36.125.38 vs_ipad
几个字段:
Trx id counter 0 3638031820 。 当前事务ID可用最大值 。下一个事物从这个ID 开始。一直增加。
Purge done for trx‘s n:o < 0 3637930396 undo n:o < 0 0。事物ID小于此值的,已完成flush dirty data及清理undo。
History list length 19988。在undo空间,没有purge的事物数。
Total number of lock structs in row lock hash table 0。所有事物持有行锁的结构体个数。每个行锁结构体有多行
数据。
25
26. TRANSACTIONS
---TRANSACTION 0 80157600, ACTIVE 4 sec, process no 3396, OS thread id 1148250464, thread declared inside InnoDB
442
mysql tables in use 1, locked 0
MySQL thread id 8079, query id 728899 localhost root Sending data
select sql_calc_found_rows * from b limit 5
Trx read view will not see trx with id >= 0 80157601, sees < 0 80157597
---TRANSACTION 0 80157599, ACTIVE 5 sec, process no 3396, OS thread id 1150142816 fetching rows, thread declared
inside InnoDB 166
几个字段:
ACTIVE/not started 。 每个TRANSACTION都会是这2个状态中的一种。TRANSACTION能够是ACTIVE,即使这个连接
是SLEEP状态(这个事物,会执行多个sql)。
Sending data,fetching rows。发送data,获取数据。
Insite InnoDB 442。线程正在innodb 内核 ,还有 442个tickets使用。
Use 1,locked 0。有1个表,在被访问,0个lock.
Innodb 线程三种状态:
Running Inside Innodb,sleeping before joining InnoDB queue 和waiting in InnoDB queue.
1. innodb_thread_sleep_delay ,在进入innodb queue,需要等待的时间。默认10,000us.
2. innodb_thread_concurrency
innodb_thread_concurrency。
26