MariaDB [(none)]> SHOW ENGINE INNODB STATUS\G


latest detected deadlock 항목에서 데드락을 확인할 수 있다.

마지막에 발생한 deadlock만 확인된다. 

내용을 보면


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

LATEST DETECTED DEADLOCK

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

2019-01-24 04:00:03 7f2914242b00 ## 데드락 발생시간

*** (1) TRANSACTION:  ##첫번째 트랜잭션

TRANSACTION 47312201250, ACTIVE 0 sec fetching rows

mysql tables in use 3, locked 3

LOCK WAIT 266 lock struct(s), heap size 30248, 2129 row lock(s)

MySQL thread id 13168615, OS thread handle 0x7f28fac80b00, query id 120397240 192.168.0.213 root updating

UPDATE `TABLE` SET `rsInstall` = '123123', `rsOpen` = '123123'   ##쿼리내용

WHERE `rsToday` = '123123'

AND `rsAdmIdx` = '123123'

AND `rsAffIdx` = '3123123'

AND `rsAdsIdx` = '123123'

AND `rsSubAffIdx` = '1123123'

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

RECORD LOCKS space id 9873 page no 170251 n bits 88 index `PRIMARY` of table `DB`.`TABLE` trx table locks 1 total table locks 2  trx id 47312201250 lock_mode X locks rec but not gap waiting lock hold time 0 wait time before grant 0     ##이부분이 지금 데드락에 빠진거고

*** (2) TRANSACTION:   ##두번째 트랜잭션

TRANSACTION 47312201244, ACTIVE 0 sec fetching rows

mysql tables in use 3, locked 3

241 lock struct(s), heap size 30248, 5827 row lock(s), undo log entries 22

MySQL thread id 13168659, OS thread handle 0x7f2914242b00, query id 120397235 192.168.0.213 root updating

UPDATE `TABLE` SET `rInstall` = '18123123, `rOpen` = '123123'   ##쿼리내용

WHERE `rsToday` = '123123'

AND `rsAdmIdx` = '123123'

AND `rsAffIdx` = '123123'

AND `rsAdsIdx` = '123213'

AND `rsSubAffIdx` = '123123'

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

RECORD LOCKS space id 9873 page no 170251 n bits 88 index `PRIMARY` of table `DB`.`TABLE` trx table locks 1 total table locks 2  trx id 47312201244 lock_mode X locks rec but not gap lock hold time 0 wait time before grant 0    ##여기도 데드락에 빠졌꼬 

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

RECORD LOCKS space id 9873 page no 170473 n bits 88 index `PRIMARY` of table `DB`.`TABLE` trx table locks 1 total table locks 2  trx id 47312201244 lock_mode X locks rec but not gap waiting lock hold time 0 wait time before grant 0    ##데드락을 해결하기위해 이부분이 롤백됨

*** WE ROLL BACK TRANSACTION (2)   


위 두개의 트랜잭션이 데드락에 빠졌꼬 이를 해결하기 위해 두번째 트랜잭션이 롤백됐음 을 확인할 수 있다.


음. 난 dba가 아니라서 이걸보고 그다음 뭘 어떠케 해줘야 하는지 모르겠네 그래도 일단 dba한테 알려는 줄 수 있는 se가 되자 

+ Recent posts