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

fix : DB 병목 개선 - FindingGameWinner에 데이터 넣을 때 NativeQuery사용 (CC-176) #47

Merged
merged 5 commits into from
Aug 22, 2024

Conversation

putdata
Copy link
Collaborator

@putdata putdata commented Aug 22, 2024

📝 작업내용

  • 실제 조회 대신 프록시 객체 사용
  • FindingGameWinner에 데이터 넣을 때 NativeQuery사용

💬 침고사항

📖 레퍼런스

@putdata putdata self-assigned this Aug 22, 2024
@putdata putdata added 익준 feat📌 기능 개발 labels Aug 22, 2024
Copy link
Collaborator

@j2noo j2noo left a comment

Choose a reason for hiding this comment

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

성능 얼마나 올랐는지도 알려주세요~~

@putdata putdata changed the title fix : DB 병목 개선 - 프록시 객체 사용 (CC-176) fix : DB 병목 개선 - FindingGameWinner에 데이터 넣을 때 NativeQuery사용 (CC-176) Aug 22, 2024
@putdata
Copy link
Collaborator Author

putdata commented Aug 22, 2024

성능 얼마나 올랐는지도 알려주세요~~

if (completed > 0) {
log.info("선착순 인원 스케쥴링 처리 완료 - {} 건", completed);
}
}

@Transactional
protected void insertWinner(Integer gameId, String phone) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

https://mangkyu.tistory.com/269
트랜잭션이 중첩되었을때, 내부 트랜잭션 단위로 커밋을 하고싶은거라면 REQUIRES_NEW인가요? 궁금!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

외부트랜잭션 insertWinnerToDatabaseScheduler 에서 내부 트랜잭션이 실패하면 지금까지 커밋된 내용은 반영되고 외부트랜잭션은 그냥 종료시키고 싶었습니다. REQUIRES_NEW를 통해서 새로운 트랜잭션을 만들어야할 것 같아요.

@@ -37,17 +37,21 @@ public void insertWinnerToDatabaseScheduler() {
if (realWinner == null) break;
Integer gameId = realWinner.getGameId();
String phone = realWinner.getPhone();
insertWinner(gameId, phone);
try {
Copy link
Collaborator

Choose a reason for hiding this comment

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

그냥 Exception을 던지고 다른 서비스에서 받는? 그런 로직? (저도잘모름) 도 생각하면 코드 깔끔할 것 같아요

@j2noo j2noo merged commit da18f6d into develop Aug 22, 2024
1 check passed
@putdata putdata added the fix🔨 버그 픽스 label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat📌 기능 개발 fix🔨 버그 픽스 익준
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants