TRANSACTIONS ------------ Trx id counter 99320 Purge done for trx's n:o < 99319 undo n:o < 0 state: running but idle History list length 12 LIST OF TRANSACTIONS FOR EACH SESSION: ---TRANSACTION 281479545798208, not started 0 lock struct(s), heap size 1136, 0 row lock(s) ---TRANSACTION 99319, ACTIVE 68 sec fetching rows mysql tables in use 1, locked 1 LOCK WAIT 3 lock struct(s), heap size 1136, 5 row lock(s) MySQL thread id 57, OS thread handle 123145382178816, query id 594 localhost root Sending data select count(*) from banner where name='a' LOCK IN SHARE MODE ------- TRX HAS BEEN WAITING 2 SEC FOR THIS LOCK TO BE GRANTED: RECORD LOCKS space id 362 page no 4 n bits 80 index index_ of table `db_test`.`banner` trx id 99319 lock mode S waiting Record lock, heap no 11 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 1; hex 61; asc a;; 1: len 4; hex 8000002b; asc +;;
------------------ TABLE LOCK table `db_test`.`banner` trx id 99319 lock mode IS RECORD LOCKS space id 362 page no 4 n bits 80 index index_ of table `db_test`.`banner` trx id 99319 lock mode S Record lock, heap no 3 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 1; hex 61; asc a;; 1: len 4; hex 8000002a; asc *;;
Record lock, heap no 7 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 1; hex 61; asc a;; 1: len 4; hex 80000003; asc ;;
Record lock, heap no 10 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 1; hex 61; asc a;; 1: len 4; hex 80000029; asc );;
RECORD LOCKS space id 362 page no 4 n bits 80 index index_ of table `db_test`.`banner` trx id 99319 lock mode S waiting Record lock, heap no 11 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 1; hex 61; asc a;; 1: len 4; hex 8000002b; asc +;;
---TRANSACTION 99314, ACTIVE 74 sec 2 lock struct(s), heap size 1136, 1 row lock(s), undo log entries 1 MySQL thread id 56, OS thread handle 123145383014400, query id 571 localhost root TABLE LOCK table `db_test`.`banner` trx id 99314 lock mode IX RECORD LOCKS space id 362 page no 4 n bits 80 index index_ of table `db_test`.`banner` trx id 99314 lock_mode X locks rec but not gap Record lock, heap no 11 PHYSICAL RECORD: n_fields 2; compact format; info bits 0 0: len 1; hex 61; asc a;; 1: len 4; hex 8000002b; asc +;;
insert 加 X 锁的原理是啥?是加在辅助索引还是主键索引上?select count() 加锁被阻塞是阻塞在主键索引还是辅助索引上?