feat(booking): 낙관적 락 적용으로 동시성 제어 개선 #97
Merged
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.
연관 이슈
작업 내용
1. Booking 엔티티에
@Version필드 추가2. BookingServiceImpl에서 synchronized 블록 제거 및 격리 수준 설정
BOOKING_LOCK상수 제거synchronized블록 제거@Transactional(isolation = Isolation.REPEATABLE_READ)적용하여 DB 레벨 격리 수준 설정3. OptimisticLockException 처리 로직 추가
BookingErrorCode에BOOKING_CONFLICT에러 코드 추가BookingConflictException예외 클래스 생성GlobalExceptionHandler에OptimisticLockException핸들러 추가409 Conflict응답 반환4. 동시 예매 테스트 작성
BookingConcurrencyTest클래스 생성논의하고 싶은 내용
충돌 발생 시 재시도 프로세스 검토 필요
현재는
OptimisticLockException발생 시409 Conflict를 반환, 프론트엔드에서 재시도하도록 구현했습니다.대안:
공유하고 싶은 내용
낙관적 락 vs 비관적 락 선택 이유
낙관적 락을 선택한 이유:
Before vs After:
테스트 결과
기타
booking테이블에version컬럼 추가