-
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] 스케줄러 의도대로 동작하지 않는 버그 수정 (#143) #144
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.
낙관적으로 바라봤던 메서드였는데 아니나다를까 자정에 딱 잡아냈네요.. 이제라도 알아채서 다행입니다..
for(String fcfsId : fcfsIds) { | ||
String eventId = fcfsId.replace(":count", "").replace("fcfs:", ""); | ||
Set<String> userIds = stringRedisTemplate.opsForZSet().range(FcfsUtil.winnerFormatting(eventId), 0, -1); | ||
// 당첨자 관련 정보 조합하여 Entity 생성 | ||
log.info("keys for FCFS Events: {}", fcfsKeys); | ||
for(String key : fcfsKeys) { | ||
String fcfsEventId = key.replace(":count", "").replace("fcfs:", ""); | ||
Set<String> userIds = stringRedisTemplate.opsForZSet().range(FcfsUtil.winnerFormatting(fcfsEventId), 0, -1); | ||
if(userIds == null || userIds.isEmpty()) { | ||
return; | ||
log.info("No winners in FCFS Event {}", fcfsEventId); | ||
continue; | ||
} |
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.
기존 return;으로 인해 운이 좋지 않게도 앞 순번의 선착순 이벤트의 당첨자가 없는 경우 메서드 자체가 종료되어 버리기에 뒤에 서있던 다른 선착순 이벤트의 결과 정보가 DB로 이동하지 못하고 붕 떠버리고 있었습니다.
continue로 바꾸어 뒷 순번 이벤트 결과도 저장할 수 있도록 고친 결과 정상 동작합니다.
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.
시연 이전에 예외를 찾을 수 있어서 다행이네요. 생각보다 심각한 버그일 수 있었는데 수정해서 다행입니다.
FcfsEvent event = fcfsEventRepository.findById(Long.parseLong(eventId)) | ||
FcfsEvent event = fcfsEventRepository.findById(Long.parseLong(fcfsEventId)) | ||
.orElseThrow(() -> new FcfsEventException(ErrorCode.FCFS_EVENT_NOT_FOUND)); | ||
|
||
List<EventUser> users = eventUserRepository.findAllByUserId(userIds.stream().toList()); | ||
List<FcfsEventWinningInfo> winningInfos = users | ||
.stream() | ||
.map(user -> FcfsEventWinningInfo.of(event, user, getTimeFromScore(stringRedisTemplate.opsForZSet().score(FcfsUtil.winnerFormatting(eventId), user.getUserId())))) | ||
.map(user -> FcfsEventWinningInfo.of(event, user, getTimeFromScore(stringRedisTemplate.opsForZSet().score(FcfsUtil.winnerFormatting(fcfsEventId), user.getUserId())))) |
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.
그 외 eventId라는 표현이 모호하다고 생각하여 fcfsEventId로 표현을 명확하게 다듬었습니다.
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.
고생하셨습니다.
#️⃣ 연관 이슈
📝 작업 내용
관련 이미지 및 자료
보시다시피 실제 prod 환경에서 자정 정각에 Redis to DB 메서드가 동작하지 않고, 이후 1분이 될 때 DB to Redis만 동작하고 있던 것을 확인하실 수 있습니다.