Skip to content

[Fix] 동시 댓글 작성 시 익명 번호 중복 부여 문제 수정 #146

@kkw610

Description

@kkw610

버그 내용

같은 질문에 여러 명이 거의 동시에 댓글을 달면 익명 번호가 중복 부여됨

익명 번호 결정 시 해당 질문의 역할별 row 수(COUNT)를 조회한 뒤 +1 하는 방식을 사용 중
COUNT를 읽고 저장하는 사이에 다른 요청이 끼어들면 같은 번호가 중복으로 부여됨

수정 사항

COUNT 대신 MAX를 사용해 이미 부여된 번호 중 최댓값 +1을 새 번호로 결정
(question_id, user_id) 조합에 유니크 제약을 추가해 DB 레벨에서 중복 저장 차단

  • QuestionAnonymousIdentityRepository에 findMaxAnonymousNoByQuestionAndRole() 추가
  • QuestionService의 assignAnonymousIdentity()에서 count → findMaxAnonymousNo로 변경
  • V5 flyway 마이그레이션 파일 추가 (question_anonymous_identity 유니크 제약)

사전 작업

배포 전 DB에서 기존 데이터 정리 필요
(question_like → question_anonymous_identity → question_comment → question 순서로 DELETE)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions