-
Notifications
You must be signed in to change notification settings - Fork 0
fix: 과팅 락 맵 누수 및 불필요한 락 최적화 #336
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
9c1b545
fix: 과팅 종료 시 회원/세션 락 맵 정리 누락으로 인한 누수 수정
2d4b19a
perf: 과팅 참여자 스토리지 락 최적화 및 소켓 조회 인덱스 추가
6c72141
perf: tryStart 불필요한 synchronized 제거
70da2c7
perf: BlindDateSessionStorageImpl 불필요한 synchronized 제거
340806e
fix: 입장 실패 시 다른 세션의 정상 등록을 지워버리는 문제 수정
d92da62
fix: 대기 중 세션에서 퇴장 시 인원수 브로드캐스트가 실행되지 않는 문제 수정
e270200
fix: SessionInfo.state에 volatile 추가
ac595c3
refactor: 과팅 락 3개를 단일 이벤트 큐로 전환
24c6706
fix: BlindDateEventQueue.submit()의 executor.execute() 호출 자체도 예외 방어
5fdcfd2
fix: 재접속 대상 세션이 이미 종료된 경우 클라이언트에 알림
8961dd2
fix: 재접속 시 socketId->memberId 역인덱스 미갱신 수정
72cb4f6
fix: 세션 종료 알림 처리에서 참가자 기록 삭제 제거
a023851
fix: 입장 등록 이후 단계 실패 시 고아 참가자 방지
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/com/dongsoop/dongsoop/blinddate/executor/BlindDateEventQueue.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| package com.dongsoop.dongsoop.blinddate.executor; | ||
|
|
||
| import java.util.concurrent.ExecutorService; | ||
| import java.util.concurrent.Executors; | ||
| import lombok.extern.slf4j.Slf4j; | ||
| import org.springframework.stereotype.Component; | ||
|
|
||
| /** | ||
| * 과팅(BlindDate) 상태 변경 이벤트를 순서대로 처리하는 단일 스레드 큐. | ||
| * <p> | ||
| * 입장/재접속/세션 시작 판단/퇴장/인원 브로드캐스트 등 참가자·세션 상태를 건드리는 작업은 | ||
| * 전부 이 큐를 통해 제출되어 하나의 스레드에서 순서대로 처리된다. 처리를 담당하는 스레드가 | ||
| * 항상 하나뿐이므로, 이 상태들에 대해서는 별도의 락이 필요 없다. | ||
| * (BlindDateMatchingLock, BlindDateMemberLock, BlindDateSessionLock 대체) | ||
| */ | ||
| @Slf4j | ||
| @Component | ||
| public class BlindDateEventQueue { | ||
|
|
||
| private final ExecutorService executor = Executors.newSingleThreadExecutor(); | ||
|
|
||
| /** | ||
| * 이벤트를 큐에 넣는다. 이미 큐에 있는 다른 이벤트들이 처리된 뒤 순서대로 실행된다. | ||
| * <p> | ||
| * executor가 이미 종료된 상태에서 호출되어도(RejectedExecutionException 등) 호출자 스레드로 | ||
| * 예외가 전파되지 않도록 방어한다. | ||
| */ | ||
| public void submit(Runnable event) { | ||
| try { | ||
| executor.execute(() -> { | ||
| try { | ||
| event.run(); | ||
| } catch (Exception e) { | ||
| log.error("[BlindDate] Event processing failed", e); | ||
| } | ||
| }); | ||
| } catch (Exception e) { | ||
| log.error("[BlindDate] Failed to submit event to queue", e); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * 애플리케이션(빈) 종료 시 큐 정리. 과팅 라운드 종료(scheduleAutoClose)와는 다른 시점이다 — | ||
| * 한 번 호출되면 이 executor는 다시 못 쓰게 되므로, 다음 과팅 라운드를 위해 라운드 종료 | ||
| * 시점에는 절대 호출하면 안 된다. | ||
| */ | ||
| public void shutdown() { | ||
| executor.shutdownNow(); | ||
| } | ||
|
|
||
| /** | ||
| * 지금까지 제출된 이벤트가 모두 처리될 때까지 대기한다. | ||
| * <p> | ||
| * 큐가 단일 스레드로 순서대로(FIFO) 처리되므로, 트리비얼 작업을 제출해 그 작업이 끝날 때까지 | ||
| * 기다리면 그 이전에 제출된 모든 이벤트의 처리가 끝났음을 보장할 수 있다. 테스트에서 비동기 | ||
| * 처리 완료를 기다릴 때 사용한다. | ||
| */ | ||
| public void awaitIdle() { | ||
| try { | ||
| executor.submit(() -> null).get(); | ||
| } catch (Exception e) { | ||
| throw new IllegalStateException("[BlindDate] Failed to await queue idle", e); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.