Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
PR Reviewer Guide 🔍(Review updated until commit dbbe6c5)Here are some key observations to aid the review process:
|
|
Persistent review updated to latest commit dbbe6c5 |
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.
User description
관련 이슈 (Related Issues)
🚀 PR 개요
Answer–Feedback 비동기 처리 구조를 리팩토링하여 데이터 정합성을 보장하고 성능을 유지했습니다.
📌 변경 배경
@Async@Transactional이 적용된 FeedbackService.saveFeedback()을 직접 호출하는 방식이었습니다.🔍 원인 분석
Spring의
@Async는 별도의 스레드와 별도의 트랜잭션에서 실행됩니다. 따라서 AnswerService.saveAnswer()에서 예외 발생 시 Answer와 Question은 롤백되지만, Feedback은 이미 커밋되어 데이터 불일치가 발생할 수 있었습니다.✅ 해결 과정
@TransactionalEventListener(phase = AFTER_COMMIT)에서만 Feedback 생성이 실행되도록 보장@Async로 비동기 처리하여 서비스 응답 속도 유지🎯 결과
PR Type
Bug fix, Tests, Enhancement
Description
이벤트 기반으로 피드백 생성 전환
트랜잭션 커밋 후 비동기 처리 보장
콘솔 로그 제거 및 예외 처리 추가
단위 테스트 추가 및 검증 강화
Diagram Walkthrough
File Walkthrough
AnswerSavedEvent.java
Answer 저장 이벤트 객체 도입src/main/java/com/project/InsightPrep/domain/question/event/AnswerSavedEvent.java
AnswerSavedEvent레코드 추가FeedbackEventListener.java
트랜잭션 후 비동기 피드백 생성 리스너src/main/java/com/project/InsightPrep/domain/question/event/FeedbackEventListener.java
AnswerServiceImpl.java
서비스에서 이벤트 발행으로 피드백 분리src/main/java/com/project/InsightPrep/domain/question/service/impl/AnswerServiceImpl.java
ApplicationEventPublisher주입AnswerSavedEvent발행FeedbackServiceImpl.java
디버그 출력 제거로 정리src/main/java/com/project/InsightPrep/domain/question/service/impl/FeedbackServiceImpl.java
FeedbackEventListenerTest.java
이벤트 리스너 단위 테스트 추가src/test/java/com/project/InsightPrep/domain/question/event/FeedbackEventListenerTest.java
AnswerServiceImplTest.java
Answer 서비스 테스트를 이벤트 기반으로 수정src/test/java/com/project/InsightPrep/domain/question/service/impl/AnswerServiceImplTest.java
AnswerSavedEvent캡처 및 값 검증