Skip to content

[fix/#385] ReadPost 조회수 동시성 이슈 해결#387

Merged
Dimo-2562 merged 6 commits into
developfrom
fix/#385
May 8, 2026
Merged

[fix/#385] ReadPost 조회수 동시성 이슈 해결#387
Dimo-2562 merged 6 commits into
developfrom
fix/#385

Conversation

@Dimo-2562
Copy link
Copy Markdown
Contributor

@Dimo-2562 Dimo-2562 commented May 8, 2026

❤️ 기능 설명

  • ReadPost 최초 조회 판정을 first_read_posts (user_id, post_id) 유니크 제약 기반으로 변경했습니다.
  • 최초 조회로 마킹된 경우에만 PostCommandService.incrementViewCount()를 호출하도록 바꿨습니다.
  • 조회수 증가 실패 시 READ_POST_VIEW_COUNT_INCREMENT_FAILED 예외를 던져 first_read_posts 마킹과 read_posts 저장이 함께 롤백되도록 보강했습니다.
  • ReadPostCommandServiceConcurrencyIntegrationTest를 추가해 같은 사용자/게시글 동시 요청에서 viewCount가 1회만 증가하는지 검증했습니다.
  • 관련 전술 설계 / 유비쿼터스 언어 문서를 최신 구현 기준으로 업데이트했습니다.

swagger 테스트 성공 결과 스크린샷 첨부
→ CLI 환경이라 스크린샷은 첨부하지 못했고, 아래 테스트 결과로 대체합니다.

테스트 결과

  • ./gradlew test --tests 'com.techfork.activity.readpost.application.command.ReadPostCommandServiceTest' --tests 'com.techfork.activity.readpost.infrastructure.FirstReadPostRepositoryTest'
  • ./gradlew integrationTest --tests 'com.techfork.activity.readpost.integration.ReadPostCommandServiceConcurrencyIntegrationTest'

연결된 issue

연결된 issue를 자동으로 닫기 위해 아래 {이슈넘버}를 입력해주세요.

close #385



🩷 Approve 하기 전 확인해주세요!

  • 이번 PR은 조회수 중복 증가 방지와 롤백 보호에 초점을 맞췄습니다.
  • 동시성 검증은 ReadPostCommandServiceConcurrencyIntegrationTest 중심으로 확인 부탁드립니다.

✅ 체크리스트

  • PR 제목 규칙 잘 지켰는가?
  • 추가/수정사항을 설명하였는가?
  • 테스트 결과 사진을 넣었는가? (CLI 환경으로 미첨부)
  • 이슈넘버를 적었는가?

@Dimo-2562 Dimo-2562 self-assigned this May 8, 2026
@Dimo-2562 Dimo-2562 added 🌟 REFACTOR 리팩터링 (기능 변화 X) 📝 domain:post 게시글 관련 🎯 domain:activity 사용자 활동 관련 (읽은 게시글, 북마크, 검색 히스토리) 🔧 FIX 버그 수정 and removed 🌟 REFACTOR 리팩터링 (기능 변화 X) labels May 8, 2026
@Dimo-2562 Dimo-2562 merged commit 08ddb93 into develop May 8, 2026
1 check passed
@Dimo-2562 Dimo-2562 deleted the fix/#385 branch May 8, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🎯 domain:activity 사용자 활동 관련 (읽은 게시글, 북마크, 검색 히스토리) 📝 domain:post 게시글 관련 🔧 FIX 버그 수정

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FIX] ReadPost 최초 읽기 판별 race condition 방지

1 participant