-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
�feat: 경매 환불 시 동시성 해결은 DB 락을 사용한다 (#316)
* feat: 경매 환불 시, 경매 Lock 획득 코드 구현 * feat: 경매 환불 시, 거래 내역 Lock 획득 코드 구현 * fix: 구매 취소 시 Select For Update로 실행하도록 코드 작성 * test: 환불 동시성 테스트 코드 작성 * fix: ReceiptEntity 식별자 GeneratedValue 제거 - 지정한 ID가 아닌 새로운 ID 생성이 되어 제거 * fix: 경매 조회 순서 변경으로 Lock 범위 변경 - verifyEndAuction의 인자를 경매의 종료 시간으로 변경합니다 * fix: 거래 내역 id 지정을 위한 추가 * fix(test): 시간 정밀도 차이를 마이크로초까지 제한한 공통 LocalDateTime 필드를 사용하도록 테스트를 수정 * refactor: 사용하지 않는 분산락 적용 코드 삭제 --------- Co-authored-by: HiiWee <[email protected]>
- Loading branch information
1 parent
918b31d
commit 1dbe550
Showing
13 changed files
with
140 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
7 changes: 7 additions & 0 deletions
7
src/main/java/com/wootecam/luckyvickyauction/core/auction/infra/AuctionJpaRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
package com.wootecam.luckyvickyauction.core.auction.infra; | ||
|
||
import com.wootecam.luckyvickyauction.core.auction.entity.AuctionEntity; | ||
import jakarta.persistence.LockModeType; | ||
import java.util.Optional; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Lock; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface AuctionJpaRepository extends JpaRepository<AuctionEntity, Long>, AuctionQueryDslRepository { | ||
|
||
Optional<AuctionEntity> findById(long id); | ||
|
||
@Lock(LockModeType.PESSIMISTIC_WRITE) | ||
@Query("select a from AuctionEntity a where a.id = :id") | ||
Optional<AuctionEntity> findByIdForUpdate(Long id); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
8 changes: 8 additions & 0 deletions
8
src/main/java/com/wootecam/luckyvickyauction/core/payment/infra/ReceiptJpaRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
package com.wootecam.luckyvickyauction.core.payment.infra; | ||
|
||
import com.wootecam.luckyvickyauction.core.payment.entity.ReceiptEntity; | ||
import jakarta.persistence.LockModeType; | ||
import java.util.Optional; | ||
import java.util.UUID; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.data.jpa.repository.Lock; | ||
import org.springframework.data.jpa.repository.Query; | ||
|
||
public interface ReceiptJpaRepository extends JpaRepository<ReceiptEntity, UUID>, ReceiptQueryDslRepository { | ||
|
||
@Lock(LockModeType.PESSIMISTIC_WRITE) | ||
@Query("select r from ReceiptEntity r where r.id = :id") | ||
Optional<ReceiptEntity> findByIdForUpdate(UUID id); | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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