Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔍 개요
EntityNotFoundException문제를 해결합니다.배경
데드락을 막기 위해 accessHistory에 배타락 조회를 했다.
문제상황
해결 방안
accessHistory를 배타락 조회하여 mvcc를 뚫어버렸기에, 락을 기다린 트랜잭션도 관련 데이터를 가져올 때 (mvcc에 막히지 않도록)락있는 조회가 필요하다. 따라서 device 조회 시에도 배타락을 걸어야 한다.
결론
방법 2가 개발자의 실수를 줄일 수 있고 직관적인 방식으로 보여서 방법 2를 선택
검증
테스트 코드를 통해 예외 상황 재현 및 해결을 검증했습니다.
다만 동시성 제어를 위해
@Transactional생략이 필요하여 테스트 코드는 커밋 대상에서 제외했습니다.테스트 코드
테스트 결과
EntityNotFoundException예외 발생✅ Checklist (완료 조건)