You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
수정내용 확인했습니다. 혹시 목요일에 이벤트리스너 이후에 트랜잭션 활성화되지 않던 이슈 원인 파악하셨나요?
아뇨 아직이요ㅠ
주문 DB 저장 이후 SpringOrderCreatedAddQueueHandler에서 처리될 때랑 그 이후에도 계속 트랜잭션에 참여 중인 것으로 확인되는데, 아직 이 원인을 모르겠네요.
기본 전파속성인 REQUIRED 상태에서 이미 커밋된 상위 트랜잭션에 참여하고, 이후에 객체를 변경하니까 다시 커밋이 되지 않는 상황으로 예상하고 있어요. 그래서 REQUIRES_NEW 로 새 트랜잭션을 열면 해결되는 것 같구요..
수정내용 확인했습니다. 혹시 목요일에 이벤트리스너 이후에 트랜잭션 활성화되지 않던 이슈 원인 파악하셨나요?
아뇨 아직이요ㅠ 주문 DB 저장 이후 SpringOrderCreatedAddQueueHandler에서 처리될 때랑 그 이후에도 계속 트랜잭션에 참여 중인 것으로 확인되는데, 아직 이 원인을 모르겠네요. 기본 전파속성인 REQUIRED 상태에서 이미 커밋된 상위 트랜잭션에 참여하고, 이후에 객체를 변경하니까 다시 커밋이 되지 않는 상황으로 예상하고 있어요. 그래서 REQUIRES_NEW 로 새 트랜잭션을 열면 해결되는 것 같구요..
(우연히 발견해서 여기도 원인 기록) @Transactional 어노테이션이 붙은 메서드의 끝까지 진행되어 커밋은 되었으나, @TransactionalEventListener로 인해 스프링 트랜잭션 동기화 컨텍스트는 활성화 중이어서 해당 문제가 발생했었습니다.
// 트랜잭션 동기화의 주요 단계
1. 커밋 준비
prepareForCommit(status)
-> 커밋을 위한 준비 작업 수행
2. commit 전
triggerBeforeCommit(status)
-> 각 synchronization.beforeCommit(readOnly) 호출
3. 완료 전
triggerBeforeCompletion(status)
-> 각 synchronization.beforeCompletion() 호출
4. 실제 커밋
doCommit(status)
-> 실제 데이터베이스 트랜잭션 커밋
5. commit 후
triggerAfterCommit(status)
-> invokeAfterCommit(synchronizations)
-> 각 synchronization.afterCommit() 호출
-> @TransactionalEventListener(AFTER_COMMIT) 실행 <<< 이 부분
6. 완전히 완료 후
triggerAfterCompletion(status, completionStatus)
-> invokeAfterCompletion(synchronizations, completionStatus)
-> 각 synchronization.afterCompletion(completionStatus) 호출
7. 최종 정리
cleanupAfterCompletion(status)
-> TransactionSynchronizationManager.clear() 호출
-> 모든 트랜잭션 리소스 정리
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
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.
✨ 작업내용
@EventListener->@TransactionalEventListener로 변경했습니다.