refactor(word): optimize indexes and transaction boundaries#335
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68af7086df
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 199655505f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
Codex Review: Didn't find any major issues. What shall we delve into next? Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
word 도메인의 인덱스와 트랜잭션 경계를 재정리하고, 단어 변형 조회/북마크 흐름의 부수 효과를 줄였습니다.
Problem
WordService내부 저장 메서드에@Transactional이 붙어 있었지만 self-invocation 구조라 실제 트랜잭션 경계가 불명확했습니다.WordVariantService가 variant가 없으면 AI 호출 후 새 variant를 저장할 수 있어, 삭제 API에 생성 side effect가 있었습니다.Solution
WordPersistenceService를 분리해Word,WordVariant,InvalidWord저장 책임과 트랜잭션 경계를 별도 Bean으로 이동했습니다.BookmarkService의 불필요한 트랜잭션을 제거해 북마크 작업이 word persistence 트랜잭션을 감싸지 않도록 했습니다.WordVariantService를 조회 전용으로 축소해 북마크 삭제 경로에서 AI 호출/저장이 발생하지 않도록 했습니다.Changes
WordPersistenceService추가: 분석 결과 저장, 강제 재분석 저장, invalid word 저장 책임 분리WordService: 저장 로직 제거, AI 호출/조회/single-flight 흐름 조율 중심으로 축소WordVariantService:getOriginalForms()조회 전용화,getOrCreateWordVariants()제거BookmarkService: bookmark write 메서드의@Transactional제거Word,WordVariant: compound index 정리 및 중복/불필요 인덱스 제거WordRepository,WordVariantRepository, 기타 repository: 미사용 메서드 제거WordAiService,WordsException: AI 분석 실패 도메인 에러 전파 보강Example
WordPersistenceService에서Word + WordVariant + InvalidWord저장 구간만 처리합니다.WordVariant매핑만 조회하고, 매핑이 없더라도 AI 호출이나 새 variant 저장을 수행하지 않습니다.검증:
./gradlew compileJava./gradlew test --tests com.linglevel.api.word.service.WordServiceTest --tests com.linglevel.api.word.service.WordVariantServiceTest --tests com.linglevel.api.word.service.WordSingleFlightRedisCoordinatorTestRelated Issues
없음