-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix : 시간표 프레임 삭제 동시성 #731
fix : 시간표 프레임 삭제 동시성 #731
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다~
@@ -18,6 +18,11 @@ public interface TimetableFrameRepositoryV2 extends Repository<TimetableFrame, I | |||
|
|||
Optional<TimetableFrame> findById(Integer id); | |||
|
|||
@Lock(LockModeType.PESSIMISTIC_WRITE) | |||
@Query("SELECT t FROM TimetableFrame t WHERE t.id = :id") | |||
Optional<TimetableFrame> findByIdWithLock(@Param("id") Integer id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A
findById 자체에 Lock을 거는 것을 생각했는데, 메소드를 따로 분리하셨네요!👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findById는 delete뿐 아니라 여러 트랜잭션에서 사용되는거라 필요한 상황에서만 쓸 수 있게 분리시켰습니다ㅋㅋ
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
🔥 연관 이슈
🚀 작업 내용
findFirstByUserIdAndSemesterIdAndIsMainFalseOrderByCreatedAtAsc()메서드에 베타락을 걸어도 여전히 위와같은 2개의 트랜잭션이 동시에 접근되는 상황에서 여전히 동시성 에러가 발생되고 있습니다. 이유는 사진과 같이 findById는 여전히 해당 레코드를 공유하여 접근하기 때문에 충돌이 발생합니다.
그래서 findById메서드 또한 베타락을 걸어서 다른 트랜잭션에서 findById 사용할때 해당 레코드에 동시에 접근하는 것을 막게 수정했습니다.
💬 리뷰 중점사항