대용량 서비스플랫폼 인데, 여러 개의 Table을 포함한 처리를 한 Session에서 길게 잡은 것이 가장 큰 실수였다.
대용량 서비스에서는 DB 사용시에는 Transaction을 과감하게 빼야 할 듯.
<서비스 확인>
java의 mysql driver에서 아래와 같이 출력.
com.mysql.jdbc.exceptions.jdbc4.MySQLTransactionRollbackException: Deadlock found when trying to get lock; try restarting transaction
<Mysql DB>
mysql> SHOW ENGINE INNODB STATUS\G
------------------------
LATEST DETECTED DEADLOCK
------------------------
1. Transaction
1. wating the lock
2. Transaction
2. holds the lock
<해결>
1. DB Session을 아주 짧게 하는 처리로 작업.
2. Where절의 순서를 교체 (insert intention waiting 방지)
=> 더 이상의 deadlock은 발생하지 않음.
참고 자료
http://dev.mysql.com/doc/refman/5.0/en/innodb-monitors.html
Real MySQL - 이성욱
'scribbling' 카테고리의 다른 글
git pull 강제로 강제로 받기 (0) | 2012.08.30 |
---|---|
알면 좋은 Apache Commons Utility (1) | 2012.08.19 |
mybatis 날 코딩할 때 참조할 소스 (1) | 2012.08.16 |
cvs, svn 보다 더 좋은 git flow (0) | 2012.08.14 |
Mybatis의 SqlSessionFactory에서 openSession() (0) | 2012.08.10 |