数据库锁--看看怎解决

[复制链接]
查看11 | 回复1 | 2010-10-8 09:28:51 | 显示全部楼层 |阅读模式
mysql> show processlist;
193 rows in set (0.00 sec)

看看怎么解决,共有193条语句在进行INSERT

mysql> show engine innodb status \G;

*************************** 1. row ***************************

Type: InnoDB

Name:

Status:

=====================================

140225 13:03:05 INNODB MONITOR OUTPUT

=====================================

Per second averages calculated from the last 18446744073709382419 seconds

-----------------

BACKGROUND THREAD

-----------------

srv_master_thread loops: 6437349 1_second, 6432433 sleeps, 609918 10_second, 355691 background, 355661 flush

srv_master_thread log flush and writes: 6848192

----------

SEMAPHORES

----------

OS WAIT ARRAY INFO: reservation count 478288080, signal count 2144244143

Mutex spin waits 21643096766, rounds 54682679530, OS waits 172373295

RW-shared spins 1137697120, rounds 7447977970, OS waits 73012753

RW-excl spins 420773247, rounds 11286838643, OS waits 202766837

Spin rounds per wait: 2.53 mutex, 6.55 RW-shared, 26.82 RW-excl

------------------------

LATEST DETECTED DEADLOCK

------------------------

1401213:21:28

*** (1) TRANSACTION:

TRANSACTION 6A82890F, ACTIVE 0 sec starting index read

mysql tables in use 3, locked 3

LOCK WAIT 9 lock struct(s), heap size 3112, 6 row lock(s), undo log entries 2

MySQL thread id 9232907, OS thread handle 0x7f6650c7f700, query id 397120625 192.168.100.22 trueqa Updating

UPDATE `lock_shanma` SET `isb` = '1' WHERE`ise` = '140121040' AND `code` = '03 02 07'

*** (1) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 0 page no 2157793 n bits 448 index `idx_code` of table `admin`.`lock_shanma` trx id 6A82890F lock_mode X waiting

Record lock, heap no 276 PHYSICAL RECORD: n_fields 3; compact format; info bits 32

0: len 8; hex 3033203032203037; asc 03 02 07;;

1: len 9; hex 313430313230303031; asc 140120001;;

2: len 4; hex 80000319; asc ;;



*** (2) TRANSACTION:

TRANSACTION 6A828775, ACTIVE 54 sec updating or deleting, thread declared inside InnoDB 126

mysql tables in use 1, locked 1

520 lock struct(s), heap size 63928, 102488 row lock(s), undo log entries 202346

MySQL thread id 9232720, OS thread handle 0x7f6652c7d700, query id 397120626 192.168.100.100 trueqa Updating

UPDATE `lock_shanma` SET `ise` = '140122103', `prs` = '0', `isde` = '0' WHERE`ise` = '140120103'

*** (2) HOLDS THE LOCK(S):

RECORD LOCKS space id 0 page no 2157793 n bits 448 index `idx_code` of table `admin`.`lock_ll11x5_shanma` trx id 6A828775 lock_mode X locks rec but not gap

Record lock, heap no 276 PHYSICAL RECORD: n_fields 3; compact format; info bits 32

0: len 8; hex 3033203032203037; asc 03 02 07;;

1: len 9; hex 313430313230303031; asc 140120001;;

2: len 4; hex 80000319; asc ;;



*** (2) WAITING FOR THIS LOCK TO BE GRANTED:

RECORD LOCKS space id 0 page no 2157793 n bits 448 index `idx_code` of table `admin`.`lock_shanma` trx id 6A828775 lock_mode X locks gap before rec insert intention waiting
Record lock, heap no 276 PHYSICAL RECORD: n_fields 3; compact format; info bits 32

0: len 8; hex 3033203032203037; asc 03 02 07;;

1: len 9; hex 313430313230303031; asc 140120001;;

2: len 4; hex 80000319; asc ;;



*** WE ROLL BACK TRANSACTION (1)

------------

TRANSACTIONS

------------

Trx id counter 6AA566EA

Purge done for trx's n

show processlist;
--------------------------------------- 省略内容
193 rows in set (0.00 sec)


回复

使用道具 举报

千问 | 2010-10-8 09:28:51 | 显示全部楼层
trx 2
UPDATE `lock_shanma` SET `ise` = '140122103', `prs` = '0', `isde` = '0' WHERE`ise` = '140120103'
*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 0 page no 2157793 n bits 448 index `idx_code` of table `admin`.`lock_shanma` trx id 6A828775 lock_mode X locks gap before rec insert intention waiting
从提示看,是插入操作的间隙锁(因为set中`ise`的值改了,产生一次插入操作)被trx1持有

如有错误,欢迎拍砖
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行