Skip to content

refactor: DB만 다루는 서비스의 트랜잭션 선언을 클래스 기본값 + 쓰기 덮어쓰기로 맞춘다 - #162

Merged
ff1451 merged 11 commits into
mainfrom
refactor/transactional-placement
Oct 18, 2026
Merged

ff1451 merged 11 commits into
mainfrom
refactor/transactional-placement

Conversation

@ff1451

@ff1451 ff1451 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

규칙

  • DB만 다루는 서비스: 클래스에 @Transactional(readOnly = true)를 두고, 쓰기 메서드에만 @Transactional을 붙입니다.
  • 외부 호출(Slack·메일·HTTP)이 있는 서비스: 클래스에는 선언하지 않습니다. 트랜잭션이 필요한 부분만 메서드나 별도 빈(*Writer·*Issuer 등)에 둡니다. 클래스에 선언하면 외부 응답을 기다리는 동안 DB 커넥션을 쥐고 있게 되기 때문입니다(#153과 같은 이유).

바꾼 것 (7개)

ExemptionService, LedgerEntryService, SemesterService, RosterService, MemberService, MemberDirectoryService, ReservationService

  • 외부 호출이 없고, 모든 public 메서드가 이미 @Transactional을 명시하던 서비스만 골랐습니다.
  • 그래서 메서드별 실효 속성(읽기 전용/쓰기)은 그대로입니다. 바꾼 뒤 서비스마다 readOnly 메서드 수와 쓰기 메서드 수가 원래와 같은지 셌습니다.
  • 7개 서비스에 package-private·protected 메서드는 없습니다. Spring 6부터는 클래스 단위 선언이 이런 메서드에도 적용되기 때문에 확인했습니다.

그대로 둔 것

  • 외부 호출이 있거나 트랜잭션 밖에서 도는 메서드가 있는 서비스
    • AuthService, PasswordResetService, AdminMemberService(@Async 메일 리스너), SlackProfileSyncService, MemberSlackIdWriter, DuesNotification*, EvidenceLinkWriter
    • ImportReader·ImportWriter: 트랜잭션 없는 public 메서드가 있습니다.
  • 쓰기 전용 트랜잭션 경계 빈: RefreshToken*, LoginSessionIssuer, LoginAttemptRecorder, DuesLinkService, DuesLinkWriter, DuesSemesterWriter (REQUIRES_NEW 등 메서드별 속성이 있는 빈 포함)
  • 메서드가 하나뿐인 조회 빈: ServiceMemberService — 클래스로 옮겨도 얻는 게 없습니다.

머지 순서

#148~#157 머지 후 main으로 rebase하고 ready로 바꿉니다. 이 PR의 변경은 마지막 커밋 하나입니다. #157이 ReservationService를 고치므로 그 뒤에 머지해야 합니다.

검증

  • 로컬: 컴파일
  • 전체 테스트: CI

ff1451 added 10 commits October 18, 2026 21:52
…into chore/merge-train

# Conflicts:
#	src/main/java/com/bcsdlab/bcsdinternalapiv2/curriculum/service/AdminCurriculumService.java
외부 호출이 없고 모든 public 메서드가 이미 @transactional을 선언하던 서비스 7개를
클래스 @transactional(readOnly = true) + 쓰기 메서드 @transactional로 바꾼다.
메서드별 실효 속성(읽기 전용/쓰기)은 그대로다.

Slack·메일·HTTP 호출이 있거나 트랜잭션 밖에서 도는 메서드가 있는 서비스(AuthService,
PasswordResetService, AdminMemberService, SlackProfileSyncService, MemberSlackIdWriter,
Dues 알림 등)와 쓰기 전용 트랜잭션 경계 빈(*Writer, *Issuer 등)은 그대로 둔다.
@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 527bfba6-9259-4169-870d-ad8cdc8bcf9c
📥 Commits

Reviewing files that changed from the base of the PR and between dd4c3d0 and 92ee9d9.

📒 Files selected for processing: 7
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/ledger/service/ExemptionService.java
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/ledger/service/LedgerEntryService.java
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/ledger/service/RosterService.java
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/ledger/service/SemesterService.java
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/member/service/MemberDirectoryService.java
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/member/service/MemberService.java
  • src/main/java/com/bcsdlab/bcsdinternalapiv2/reservation/service/ReservationService.java
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ff1451
ff1451 marked this pull request as ready for review October 18, 2026 13:39
@ff1451
ff1451 merged commit 58d15f9 into main Oct 18, 2026
3 checks passed
@ff1451
ff1451 deleted the refactor/transactional-placement branch October 18, 2026 14:01
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.

1 participant