SSE 재연결 시 놓친 알림 replay (Last-Event-ID 기반)#751
Open
m-a-king wants to merge 1 commit into
Open
Conversation
- notification 이벤트에만 SSE id(알림 PK)를 싣는다. 별도 카운터 대신 DB 영속 값을 써 재시작·blue-green 과 무관하게 단조 증가하고, payload 의 id 와 같은 값이라 클라 dedup 키를 겸한다 - id 없는 이벤트(connect·silent-sync·하트비트)는 SSE 프로토콜상 클라 lastEventId 를 갱신하지 않으므로, 비영속이라 replay 불가능한 이벤트가 복구 기준점에서 자연 제외된다 - subscribe 가 Last-Event-ID 헤더를 받아 초과분을 발생 순서(id asc)로 그 연결에만 replay 한다. register 후 replay 순서로 "유실 대신 중복"을 택했고, 클라가 id 로 dedup 하는 계약을 스펙에 명시 - 상한(100건) 초과 공백은 일부만 보내면 replay 구간 뒤에 조용한 구멍이 남으므로 통째로 생략하고 기존 목록/배지 재조회 계약에 맡긴다 - 숫자가 아닌 Last-Event-ID 는 400 으로 끊지 않고 첫 연결로 취급한다 — EventSource 자동 재연결 루프를 깨지 않기 위함 - replay 조회는 기존 idx_notifications_user_id_id (user_id, id) 인덱스가 그대로 받쳐 마이그레이션이 없다
|
Discord 스레드 연동용 메타데이터입니다. discord-pr-bot 워크플로가 자동 생성하며, 수정·삭제하면 PR 과 Discord 알림 연동이 끊깁니다. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Situation
name+data만) 클라이언트가 재연결할 때 끊김 동안 발생한 알림을 스트림 차원에서 복구할 수단이 없었다.Task
Action
설계 결정
id와 같은 값이라 클라 dedup 키를 겸한다notification이벤트만connect·silent-sync·하트비트가 복구 기준점을 오염시키지 않게 자연 제외된다구현
LocalSseDelivery가 notification 이벤트 빌드를 한 곳(notificationEvent)에 모아 SSEid필드에 알림 PK 를 싣고, 라이브(deliver)와 replay(replayTo)가 같은 셰입을 공유한다.SseReconnectReplayer(신규)가Last-Event-ID초과분을 발생 순서(id asc)로 조회해 재연결한 그 연결에만 흘려보낸다. 조회는 리포지토리의 짧은 트랜잭션으로 끝나고 emitter write 는 트랜잭션 밖이다.subscribe가Last-Event-ID헤더를 optional 로 받는다. 숫자가 아니거나 양수가 아니면 무시하고 첫 연결로 취급한다.idx_notifications_user_id_id (user_id, id)인덱스가 그대로 받친다. 마이그레이션 없음.계약 문서
notification-sse-spec.md: id 필드, Last-Event-ID replay, 상한, 중복 dedup, 희귀 race 한계(PK 발급 순서와 커밋 순서 어긋남)를 명문화. WEB 은 EventSource 가 자동으로 처리하고, APP 은 마지막 id 저장·전송 예시를 추가했다.NotificationSseApi: Last-Event-ID 헤더 파라미터와 replay 계약을 OpenAPI 설명에 반영했다.Result
연관 이슈