Conversation
suspend 함수에 @transactional을 직접 적용하면 안 되는 이유와 동기 @component로 위임하는 권장 패턴을 정리했다. - AOP 프록시 + ThreadLocal 메커니즘 배경 설명 - 안티패턴과 실패 모드 정리 - TransactionalMetadataUpdater 위임 패턴 코드 예시 - REQUIRES_NEW로 배치 부분 성공 격리하는 이유 - 회귀 방지 통합 테스트(shouldIsolateTransactionsBetweenEvents) 인용 - 리뷰/구현 시 사용할 체크리스트 관련 이슈: #166, #224
This was referenced Apr 27, 2026
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.
요약
PR #238에서
MetadataRefreshServiceImpl.refreshEventsuspend 함수의@Transactional을 제거하고 동기TransactionalMetadataUpdater로 위임한 패턴을, 팀 차원에서 재발 방지/온보딩용으로 문서화했다.배경
Dispatchers.IO/withContext등으로 스레드를 갈아타는데, Spring@Transactional은 AOP 프록시가 시작 스레드의TransactionSynchronizationManagerThreadLocal에 트랜잭션을 매단다.@Transactional을 붙이면 트랜잭션이 코루틴과 함께 이동하지 못해 부분 커밋·예측 불가 롤백·연결 누수가 발생한다.문서 구성
docs/architecture/coroutine-transactional.md(한국어, 7개 섹션):@Transactional을 붙였을 때의 실패 모드@Component로 위임 (TransactionalMetadataUpdater코드 예시)REQUIRES_NEW채택 이유 — 배치 부분 성공 격리, REQUIRED와의 비교shouldIsolateTransactionsBetweenEvents본문 인용리뷰 포인트
TransactionalMetadataUpdater.kt패턴과 일치하는지docs/architecture/문서들과 어울리는지영향 범위
문서 단일 파일 추가 (
docs/architecture/coroutine-transactional.md, +238). 코드/빌드 변경 없음.