fix(backend): 재개 후 늦게 온 꼬리질문 콜백이 살아있는 질문을 둘로 만들던 문제 - #182
Merged
Conversation
이어하기(#180)가 terminal 가드의 전제를 깼다. 종료 세션에 늦게 도착한 콜백은 `isTerminal()` 로 드롭되지만, **재개된 세션은 IN_PROGRESS 라 그대로 통과한다.** 경합: 1. 꼬리질문 요청 → placeholder("(생성 중)") 생성 2. 사용자 중단 → INTERRUPTED 3. 사용자 이어하기 → 복구가 placeholder 를 FAILED 로 확정하고 다음 일반질문 발행 4. **뒤늦게 AI 콜백 도착** → 세션이 IN_PROGRESS 라 terminal 가드를 통과 → `completeFollowup` 이 FAILED placeholder 를 덮어써 질문으로 되살림 결과적으로 살아있는 질문이 두 개가 되고(실패로 표시됐던 꼬리질문 + 복구가 발행한 일반질문), TTS 도 그 자리에 붙는다. `applyFollowup` 에서 placeholder 가 이미 FAILED 면 그 턴은 지나간 것으로 보고 드롭한다. POOL 경로는 `countBySessionId > 0` 로 이미 멱등이라 같은 문제가 없다(재개 시 풀 재요청이 있어도 중복 저장되지 않는다). 테스트: `apply_followupOnFailedPlaceholder_isDropped` — 실패 상태·문구가 유지되고 save 가 호출되지 않는지 확인.
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.
변경 사항
#180(이어하기) 후속 검토에서 나온 두 번째 결함. 이어하기가
isTerminal()가드의 전제를 깼다.종료 세션에 늦게 도착한 콜백은 terminal 가드가 드롭한다. 그런데 재개된 세션은 IN_PROGRESS 라 그대로 통과한다. 재개 이전에는 INTERRUPTED 가 영구 상태였으므로 이 창이 열리지 않았다.
경합
"(생성 중)") 생성FAILED로 확정하고 다음 일반질문 발행completeFollowup이 FAILED placeholder 를 덮어써 정상 질문으로 되살림결과: 살아있는 질문이 두 개(실패로 표시됐던 꼬리질문 + 복구가 발행한 일반질문). TTS 도 그 자리에 붙고, 사용자의 다음 답변은 마지막 메시지에만 달려 앞의 질문은 답 없는 채로 남는다.
창이 좁아 보이지만 중단 직후 바로 이어하기를 누르거나 AI(Pro 모델)가 느릴 때 충분히 열린다.
수정
applyFollowup에서 placeholder 가 이미FAILED면 그 턴은 지나간 것으로 보고 드롭한다.FAILED placeholder 가 생기는 경로는 두 가지이고 둘 다 "이 턴은 끝났다"를 뜻한다 — 생성 실패 처리(
applyFollowupFailed)와 이어하기 복구(SessionResumeService.recoverTurn). 어느 쪽이든 되살아나면 안 된다.POOL 경로는 이미 안전하다
같은 경합이 질문 풀에도 있는지 확인했다. 이어하기 복구가 풀 생성을 재요청하는 경우, 원래 콜백과 새 콜백이 둘 다 도착할 수 있다. 그런데
applyInitialQuestion에 이미countBySessionId > 0가드가 있어 두 번째는 무시된다 — 별도 수정이 필요 없었다.테스트
apply_followupOnFailedPlaceholder_isDropped— FAILED placeholder 에 늦은 콜백이 와도 상태·문구가 유지되고save가 호출되지 않는지 확인.backend
test통과(ArchUnit 포함).영향 범위