[NOOK-189] 사용자 저장 게시물별 장소 연결 분리 - #122
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5a0ce005be
ℹ️ 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".
| FROM user_saved_posts saved_post | ||
| INNER JOIN post_places post_place ON post_place.post_id = saved_post.post_id; |
There was a problem hiding this comment.
Repeat the backfill after legacy writers stop
During a rolling deployment, this one-time INSERT ... SELECT can finish while old-version instances continue creating user_saved_posts or post_places; those instances never write user_saved_post_places, and the new code has no reconciliation path for an already-created saved post, so affected users permanently see missing places after the rollout. Either dual-write during the transition or run an idempotent catch-up backfill after every legacy instance has stopped.
AGENTS.md reference: AGENTS.md:L40-L41
Useful? React with 👍 / 👎.
| userSavedPostLockRepository.findAllByPostIdForUpdate(postId).forEach { savedPost -> | ||
| val savedPostId = requireNotNull(savedPost.id) | ||
| userSavedPostPlaceRepository.insertAllFromPost(savedPostId, postId) |
There was a problem hiding this comment.
Serialize parsing completion with concurrent saves
When a new user saves this source while completion is in progress, the save transaction can hold its new user_saved_posts row while insertAllFromPost waits on the uncommitted post_places writes, and this FOR UPDATE query then waits on that saved-post row, forming a MySQL lock cycle. One transaction is aborted, potentially returning a 500 from the save path or delaying parsing until timeout because no deadlock retry exists; acquire the same source-post lock/order used by PostPersistenceAdapter or add an explicit retry/reconciliation strategy.
AGENTS.md reference: AGENTS.md:L52-L54
Useful? React with 👍 / 👎.
목적
동일 Instagram URL의 파싱 원본은 재사용하되, 사용자가 저장한 게시물의 장소 추가·삭제가 다른 사용자에게 영향을 주지 않도록 장소 연결의 소유 경계를 사용자 저장 게시물로 분리합니다.
범위
user_saved_post_places테이블과 기존 관계 backfill DDL 추가DELETE /api/v1/posts/{postId}/places/{placeId}장소 연결 삭제 API 추가제외 범위
검증
./gradlew --no-daemon checkuser_saved_post_places생성 및 기존 552개 관계 backfill 확인