Step 12: 동시성 제어 고도화 (비관적락, 낙관적락, 분산락)#29
Merged
kilhyeonjun merged 6 commits intomasterfrom Nov 3, 2024
Merged
Conversation
jyjae
reviewed
Nov 2, 2024
| return concertQueryService.getReservation(new GetReservationByIdQuery(reservationId)); | ||
| } | ||
|
|
||
| @Deprecated(forRemoval = false) |
There was a problem hiding this comment.
@deprecated(forRemoval = false) 사용하신거 너무 좋은거 같습니다.
|
|
||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target(ElementType.METHOD) | ||
| public @interface DistributedLock { |
Contributor
Author
There was a problem hiding this comment.
기본적으로 공통값을 가져가고 추후 변경이 필요하면 추가하는게 좋을 것 같다고 생각했어요!
수정되는 case가 비지니스가 느려져서 공통으로 설정된 값보다 커져야하는 경우일 것 같은데 이건 비지니스 속도를 올리는 방법으로 개선해야되지않을까해서 강제한 느낌도 있습니다!
|
|
||
| @Aspect | ||
| @Component | ||
| @Order(Ordered.HIGHEST_PRECEDENCE + 1) |
Contributor
Author
There was a problem hiding this comment.
트랜잭션 어노테이션과 같이 사용했을때 Lock 획득을 먼저하기위해서 사용했습니다. 트랜잭션 어노테이션의 순서는Ordered.HIGHEST_PRECEDENCE 이더라구여
|
오늘도 많이 배워갑니당.. aop 활용은 안해봤는데 현준님 코드덕에 맛보고 갑니다 👍🏼 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
요구사항
작업 내용
redis 분산락 추가 (b10f7a5, 4e7849e)
#28 에서 좌석예약, 잔액 충전, 잔액 결제(예약 내역 결제)에 대해 분석하여 적용할 락을 정했습니다.
좌석 예약 분산락 추가 및 테스트 (7d6cc14)
사용자 잔액 충전 낙관적락, 분산락 추가 및 테스트 (9a1019e)
예약 내역 결제 낙관적락, 분산락 추가 및 테스트 (62d4876)
선택 동시성 제어 방법 API에 적용 (bc3da39)
좌석 예약 - 낙관적락
잔액 충전 - 분산락, 낙관적락
잔액 결제(예약 내역 결제) - 분산락, 낙관적락
코드 구현
각 usecase 별 비관적락, 낙관적락, 분산락 구현 및 통합 + 동시성 테스트를 진행했습니다.
사실 잔액과 좌석 entity에 @Version 어노테이션에 의해 모든 동시성제어에 낙관적락이 포함되어있습니다.
하지만 비관적락과 분산락의 경우 낙관적락에 의한 충돌이 안나오고 나온다면 error로 생각하고 작성했기에 감안해서 봐주시면 좋을 것 같습니다.
리뷰포인트