Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: TickerService 예매, 테스트 코드 추가 #11

Merged

Conversation

gominnam
Copy link
Collaborator

📌 변경 사항

  • Ticket 예매 비지니스 로직 추가
  • TicketServiceTest 추가

🤔 고민한 점

  • reserveTickets의 데이터 충돌이 자주 발생하는 상황으로 가정하여 비관적인 락으로 처리하도록 하였습니다.
  • 비관적인 락에서 Dead Lock이 발생할 수 있기 때문에 SQL에서 FOR UPDATE NOWAIT 을 추가하여 대기하지 않고 바로 예외처리 발생시키도록 하였습니다.

😅 실수한 부분

  • Github Branch 관리 실패로 충돌이 발생하여 application.properties 파일을 추가 하여 요청하게 됐습니다..

@gominnam gominnam closed this Feb 17, 2025
@gominnam gominnam assigned gominnam and f-lab-troy and unassigned gominnam Feb 17, 2025
@gominnam gominnam reopened this Feb 17, 2025
@gominnam gominnam closed this Feb 17, 2025
@gominnam gominnam requested a review from f-lab-troy February 17, 2025 12:22
@gominnam gominnam reopened this Feb 17, 2025
throw new TicketsNotAvailableException();
}

Duration expirationTime = Duration.ofMinutes(5);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number는 상수처리하시면 좋습니다


@Override
@Transactional
public void reserveTickets(TicketDTO ticketDTO) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

동시성 문제를 발생 시킨 후에 문제 해결을 하여 왜 문제가 발생하였고 어떻게 해결 됐는지를 문서화 해두면 좋습니다

@Override
@Transactional
public void reserveTickets(TicketDTO ticketDTO) {
try {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ticket 검증로직과 reserve로직을 다른 메서드로 분리하면 어떤 장점이 있을지 고려해보면 좋습니다


spring.datasource.url=jdbc:mysql://localhost:3306/safeticket_db
spring.datasource.username=root
spring.datasource.password=password

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

사용자 정보와 같이 보안상 예민한 정보를 노출하지 않는 방법을 고려해보시기 바랍니다

@gominnam gominnam merged commit 397899c into feature/3-ticket-api-ticket Feb 18, 2025
1 check passed
@gominnam gominnam deleted the feature/3-ticket-api-ticket-service branch February 18, 2025 04:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants