-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[fix] 선착순 이벤트 코드 수정 (#41) #42
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
코로나로 컨디션이 안 좋아서 제가 놓친 부분이 있을 수 있습니다. 살펴보시고 의문 있으시면 코멘트 주세요:)
// 이벤트 종료 여부 확인 | ||
if (isEventEnded(eventSequence)) { | ||
return false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
모든 구현방안이 항상 이벤트 종료 Flag를 확인한 뒤 시작하도록 통일했습니다.
단, RedisSetFcfsService의 경우 isEventFull() 메서드 내부에 isEventEnded() 메서드를 한번 더 배치하여 여러 스레드가 접근했을 때 동시성 이슈를 발생시키지 않고 종료할 수 있도록 설정했습니다. 만약 없다면 간헐적으로(5번에 1번 꼴로) 동시성 이슈가 발생하게 됩니다.
private boolean isParticipated(Long eventSequence, String userId){ | ||
return Boolean.TRUE.equals(stringRedisTemplate.opsForSet().isMember(FcfsUtil.participantFormatting(eventSequence.toString()), userId)); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isEventEnded(), endEvent() 외에도 "참여" 여부를 별도로 판정하기 위해 isParticipated()를 두었습니다.
private boolean isEventEnded(Long eventSequence) { | ||
return Boolean.TRUE.equals(booleanRedisTemplate.opsForValue().get(FcfsUtil.endFlagFormatting(eventSequence.toString()))); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fcfsId를 바로 key에 넣는 것을 초반에 시도했었는데 이것이 수정되지 않은 것을 확인하여 모두 고쳤습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생하셨습니다. 어제 수업을 듣고 나니까 분산 환경에서 완전한 일관성은 어려울 수 있겠다는 생각이 드네요. 하지만, 선착순 이벤트는 여전히 일관성을 지켜야 한다는 부분이 참 어려운 것 같습니다.
#️⃣ 연관 이슈
📝 작업 내용
참고 이미지 및 자료
Team AwesomeOrange 선착순 이벤트 구현방안 및 성능 보고서
💬 리뷰 요구사항