[BE] refactor: serializable 제거 및 동시성 테스트 추가 #519
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.
Issues
논의사항
동시성 테스트
코드
1. serializable + not unique
데드락이 발생합니다.
innoDB의 serializable은 기본적으로 모든 단순읽기에도 s lock을 걸기때문에
인터뷰가 생성될때
tx2 가 availableDateTIme의 레코드를 읽으며 s lock을 건다.
tx2이 availableDateTime 을 수정하려고 x lock을 걸때 tx1의 s lock 때문에 기다린다.
이러한 문제로 데드락이 발생합니다.
-> 틀린 설명
현재 테스트코드는 H2로 돌아가는데 H2 의 serializable은 innoDB처럼 돌아가지 않습니다. (읽기에 slock을 거는 것이 아닙니다)
그럼 데드락이 왜 터질까?
2. repeatable read + not unique
동시성 문제가 발생합니다.
unique가 걸려있지 않기 때문에 2개의 Interview가 동시에 생성이 되었습니다.
3. repleatable read + unique
unique 제약조건으로 DB에러가 터집니다.
동시에 Interview가 생기지 않기 때문에 이대로 해결하는 방식이 좋아 보입니다.
DB에러이기 때문에 500에러가 터지는데 500 에러로 두는 것과 400에러로 바꾸는 방식중에는 회의를 해봐야할 것 같습니다!
close #510