Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/delivery-and-settlement-models/concept/concept-adapter-outbound-persistence-mongo-c07.md
T
DongHyeonkaandClaude Fable 5.1 b25357c48a docs(clean-architecture-backend-template): fold analysis into final and re-select one topic
- analysis/·source-index·state.json 을 final/document.md 제2부·제3부로 접었다. SSOT 는 하나다
- 파일럿 — commit-ambiguity-as-a-result 를 새 기준으로 재선별. 후보 14 → 글감 5
  (PROMOTE 5 · MERGE_INTO 3 · KEEP_IN_SSOT 4 · 보류 2). 기록 5건을 다시 썼고 그림 1개를
  techviz 로 만들었다
- 재선별이 잡은 것: 제1부 §6.2·§11.1 이 자기 §13.2 와 어긋나 있었다(레인을 안 돌렸다 vs
  돌렸다) — 정정. 이미 답이 나와 있던 Question 을 HEAD 재실행 질문으로 다시 세웠다.
  Concept 이 인용한 코드가 SSOT 에 없어 뺐다
- candidateScope·sourceRepository 기록. 나머지 43개 주제는 재선별 대기(PENDING 905)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-07 12:39:20 +09:00

4.1 KiB

kind, slug, title, topic, project, status, sourceRevision, rootTreeNode, evidenceCapturedOn, assets, evidence, source, module
kind slug title topic project status sourceRevision rootTreeNode evidenceCapturedOn assets evidence source module
CONCEPT adapter-outbound-persistence-mongo-c07 투영 먼저 checkpoint 나중, 그리고 3-state claim delivery-and-settlement-models clean-architecture-backend-template 게시 전 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 concept:adapter-outbound-persistence-mongo-c07 2026-09-01
key file
adapter-outbound-persistence-mongo-c07 ../../../final/evidence/rendered/adapter-outbound-persistence-mongo-c07.svg
../../../final/evidence/raw/adapter-outbound-persistence-mongo-c07.txt
원본 분석 절은 final/document.md#a06#L1015 이다.
adapter-outbound-persistence-mongo

투영 먼저 checkpoint 나중, 그리고 3-state claim

이 leaf에서 유일하게 조립까지 된 대형 서브시스템이고, 그 설계의 규칙 대부분이 과거 결함을 이름으로 적어 두고 있다.

본문

앞선 sub-scope들과 다르다. MongoPlatformAutoConfiguration이 두 개의 bean을 실제로 만든다.

  • mongoChangeStreamSource(209행) — SpringReactiveChangeStreamSource, 무조건.
  • reactiveMongoChangeStreamConsumer(235행) — fork만 공급할 수 있는 5종(MongoChangeStreamSubscription, MongoResumeCheckpointStore, MongoResumeTokenCodec, MongoChangeProjector, MongoChangeDeduplicationStore)에 @ConditionalOnBean.

MongoPlatformAutoConfiguration 참조 위치

:::evidence key="adapter-outbound-persistence-mongo-c07" alt="코드베이스에서 MongoPlatformAutoConfiguration 를 검색한 출력 14줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="MongoPlatformAutoConfiguration 코드베이스 검색 — 14줄 · exit 0" zoom="true" :::

fork가 다섯을 채우면 완성된 소비자가 돈다

pipeline·runner·recovery policy·invalidate recovery는 auto-configuration이 직접 new한다. 이 사실이 아래 §67의 심각도를 결정한다.

순서가 계약이다

MongoChangeStreamRunner는 투영 먼저, checkpoint 나중이다 — "Checkpointing first would mean a crash between the two loses the event permanently, with no trace." 그래서 중복을 택하고 중복을 제거한다.

읽고-쓰기가 동시성에서 살아남지 못했다

과거 alreadyProjected + markProjected는 동시에 false를 읽은 두 subscriber가 둘 다 투영했다 — "the deduplication that exists precisely because redelivery is guaranteed did not survive concurrency". 지금은 CLAIMED/ALREADY_COMPLETED/BUSY의 원자적 전이다.

빈 완료는 프로토콜 위반이다

Mono<Boolean>이 empty로 완료되면 flatMap을 그냥 통과해 "투영도 checkpoint도 없이 아무도 문제를 보고하지 않는" 상태가 됐다. 이제 switchIfEmpty(Mono.error(...))로 잡는다.

구분자를 0x1F로 고른 이유

identity는 SHA-256이고 구분자는 ASCII unit separator(0x1F)다 — namespace/clusterTime/operationType에 나타날 수 없으므로 필드 재배열로 다른 이벤트의 identity를 위조할 수 없다. 한 transaction이 같은 문서를 두 번 고치면 앞 네 필드가 모두 같아지므로 txnNumber+lsid discriminator를 추가로 넣는다 — 없으면 두 번째가 첫 번째의 재전달로 버려진다.

로그에 찍히면 안 되는 것

MongoResumeCheckpoint.toString()은 길이만 보고한다. token은 clusterTime과 documentKey를 인코딩하므로 로그에 찍는 순간 production write의 모양과 타이밍이 샌다.

기본 구현을 일부러 두지 않았다

MongoResumeTokenCodec에는 기본 구현이 없다 — "a built-in that merely encoded would be worse than none: it would satisfy the type and none of the reason for it." HISTORY_LOST는 자동 복구하지 않는다 — "resuming from now… the projection then looks healthy and is quietly wrong, which is worse than a stopped consumer somebody has to look at." MongoClusterTime은 숫자로 비교한다 — 텍스트 비교는 1700000000.101700000000.9보다 앞에 놓는데, 그것은 바쁜 1초가 정확히 만드는 경우다.