Conversation
Member
Author
|
/gemini review |
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.
🙋🏻 𝗪hat
1️⃣ 낙관적 락 적용
Payment 엔티티에 @Version 필드 추가
동시 승인 요청 시 version 충돌을 통해 1건만 승인 확정
2️⃣ 금액 검증 로직 추가
카카오 승인 응답 금액과 DB 저장 금액 비교
불일치 시 FAIL 처리 및 예외 발생
3️⃣ 상태 기반 설계 강화
READY 상태에서만 APPROVED 가능하도록 제어
이미 처리된 상태(APPROVED/FAIL) 재요청 시 예외 처리
4️⃣ 동시성 통합 테스트 추가
멀티 스레드 환경에서 승인 요청 동시 실행
최종 상태가 APPROVED 1건만 유지되는지 검증
📎 𝗪𝗼𝗿𝗸 𝗗𝗲𝘀𝗰𝗿𝗶𝗽𝘁𝗶𝗼𝗻
💬 Test
단위 테스트: 금액 불일치 / 중복 승인 요청 예외 검증
통합 테스트: 멀티 스레드 기반 동시 승인 요청 시 낙관적 락 충돌 검증
외부 API 호출은 @MockBean RestTemplate으로 Mock 처리