DB/Mysql
[Mysql] Mysql InnoDB의 데드락 상황 회피관련 DeadLock Victim에 대해
OverTheHorizon3410
2024. 1. 29. 20:51

MySQL :: MySQL 8.0 Reference Manual :: 15.7.5 Deadlocks in InnoDB
A deadlock is a situation where different transactions are unable
to proceed because each holds a lock that the other needs. Because
both transactions are waiting for a resource to become available,
neither ever release the locks it holds.
MySQL :: MySQL 8.0 Reference Manual :: 15.7.5.2 Deadlock Detection
When deadlock
detection is enabled (the default),
InnoDB automatically detects transaction
deadlocks and rolls back a
transaction or transactions to break the deadlock.
InnoDB tries to pick small transactions to
roll back, where the size of a transaction is determined by the
number of rows inserted, updated, or deleted.
- 에 따르면 InnoDB의 경우 별도
- 데드락 탐지가 활성화 되어 있는 경우( 기본 설정임 )
설정 => innodb_deadlock_detect 관련 변수임
- 데드락 교착에 빠진 경우 하나의 희생양 트랜잭션을 롤백하여 데드락에서 빠져나가도록 설정한다고 한다.
- 데드락 탐지가 활성화 되어 있는 경우( 기본 설정임 )
그렇다면, 데드락에 대한 고민을 어플리케이션 단에서 할 필요는 없는건가?
- 그건 아닌 것같다.
- DB 설정에 따라 데드락에 걸릴 수도 있기에, DB 영역과 어플리케이션 영역은 서로 반 독립적이고 생각하고, 개발을 해야한다.
- 결국 비관적락이나 낙관적락 이든 어플리케이션 단에서는 항상 고민하면서 만약의 상황을 대비해야한다.
추가
- 데드락에 빠진 마지막 트랜잭션에 대한 확인은
SHOW ENGINE INNODB STATUS
- 으로 가능하다.
추가
- 데드락 탐지 관련 기능은 MYSQL 5.7 문서부터 보인다.
- 아마 5.6 7 전후 시기에 추가된 기능같다.
Uploaded by N2T