Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/owner-safe-state-machines/case/case-expired-claim-versus-expired-execution.md
T
DongHyeonkaandClaude Opus 5 b2963105a8 docs(keycloak-session-store): import the session-storage lab as a new project
The keycloak project ended with four open questions that design could not
settle. A two-VM lab was built to answer them by measurement, and this is
that material: 26 experiments, 125 raw command outputs, 22 browser captures.

Follows the import procedure in README.md.

  source/     the originating repository verbatim — 78 documents, 28 SVGs,
              8 manifests, plus .source-revision recording the commit
  final/      the SSOT
    document.md   729 lines written from the 29 experiment documents, not
                  concatenated: what was predicted, what was measured, and
                  where the measurement itself was wrong
    evidence/raw    125 outputs, flattened to <experiment>__<file> because
                    the originals collided (01-baseline.txt appeared three
                    times) and the audit only globs the top level
    evidence/meta   one per raw file; command and exitCode are null and the
                    README says why rather than inventing them
    evidence/browser  22 captures
    assets/       three diagrams through techviz
    .techviz/     their VizSpecs

A separate project rather than an addition to keycloak: the B-layer answers
that project's four questions, but the A, C and D layers are about cluster
failure, SSO and operations, and one document.md should hold one subject.
The four question records there can point here through 관계.

Recorded rather than papered over: only three of the 28 diagrams were
remade. The repository forbids hand-drawn SVG and forbids titles inside the
canvas; all 28 originals carry both, so converting them is redrawing, not
reformatting. They stay in source/ and the gap is written into the document.

verify-pipeline.py passes. audit-records.py reports no issues.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-04 22:51:59 +09:00

4.6 KiB

kind, slug, title, topic, project, status, sourceRevision, rootTreeNode, evidenceCapturedOn, assets, evidence, source
kind slug title topic project status sourceRevision rootTreeNode evidenceCapturedOn assets evidence source
CASE expired-claim-versus-expired-execution 만료된 CLAIMED는 takeover하고 만료된 EXECUTING은 조정을 요구하도록 갈랐다 owner-safe-state-machines clean-architecture-backend-template 게시 전 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 case:expired-claim-versus-expired-execution 2026-09-01
key file
expired-claim-versus-expired-execution ../../../final/evidence/rendered/expired-claim-versus-expired-execution.svg
../../../final/evidence/raw/expired-claim-versus-expired-execution.txt
원본 분석 절은 analysis/05 §10.1, §10.4 이다.

만료된 CLAIMED는 takeover하고 만료된 EXECUTING은 조정을 요구하도록 갈랐다

리스가 만료된 두 상태를 같이 다루면 안 된다. 청구만 하고 실행하지 않은 소유자는 밀어내도 되지만, 실행을 시작한 소유자는 무엇을 했는지 알 수 없으므로 조정으로 넘긴다.

관계

  • 만료된 claim과 만료된 실행은 다르게 다뤄야 한다 이 사례에서 끌어낸 규칙이다.
  • 모르는 것은 성공도 실패도 아닌 세 번째 결과여야 한다 조정으로 넘기는 판정이 그 규칙의 적용이다.
  • fenced lease — 만료 시각만으로는 부족한 이유 리스 만료를 다루는 맥락이다.

문제

리스가 만료되면 다른 작업자가 그 레코드를 가져갈 수 있어야 한다. 그러지 않으면 죽은 작업자의 레코드가 영원히 막힌다.

문제는 만료된 소유자가 무엇을 하다가 만료됐는지에 따라 안전한 처리가 다르다는 점이다.

결론

청구 결정 트리가 두 상태를 갈라 다르게 답한다.

같은 소유자 토큰이면 연산 충돌로 답한다 상태가 CLAIMED 이고 리스가 지났으면 청구를 재설정한다. 즉 가져간다 상태가 재시도 가능 실패면 마찬가지로 재설정한다 상태가 EXECUTING 이고 리스가 지났으면 복구 필요로 답한다 상태가 포기됨이면 복구 필요로 답한다 그 외에는 진행 중으로 답하고 재시도 시각을 준다

CLAIMED 는 자리를 잡았지만 아직 아무것도 실행하지 않은 상태다. 그 소유자를 밀어내도 외부 효과가 없다.

EXECUTING 은 실행을 시작한 상태다. 그 소유자가 무엇을 어디까지 했는지 이 저장소는 모른다. 밀어내고 다시 실행하면 그 작업이 두 번 일어날 수 있다.

그래서 EXECUTING 만료는 자동 처리 대상이 아니라 조정 대상이다. 결과 타입이 복구 필요라는 별도 값을 갖고, 그 값이 시도 번호를 함께 들고 간다.

같은 구별이 해제 경로에도 있다. 소유자 튜플이 다르면 소유자 아님으로 답하고, 상태가 이미 EXECUTING 이면 실행이 시작되었음으로 답하며, CLAIMED 가 아니면 연산 충돌로 답한다. 해제는 아직 실행하지 않은 청구에 대해서만 허용된다.

같은 형태가 인박스 어댑터에도 있다.

검증 환경

OpenJDK : 21.0.12 데이터베이스 : PostgreSQL 확인 방식 : 결정 트리와 그 javadoc 확인 소스 수정 : x

재현 조건

  1. 소유자 안전 멱등성 저장소의 청구 결정 트리를 읽는다.
  2. CLAIMED 만료와 EXECUTING 만료가 각각 어떤 결과를 내는지 확인한다.
  3. 해제 경로의 상태 검사를 확인한다.
  4. 인박스 어댑터의 같은 형태를 비교한다.

본문

만료된 lease를 일률적으로 takeover하면 이미 실행이 시작된 작업을 blind retry하게 된다.

이 저장소는 상태로 나눈다

만료된 CLAIMEDresetClaim으로 takeover하고, 만료된 EXECUTINGabandonExpiredExecution으로 ABANDONED에 넣고 RecoveryRequired를 반환한다.

RecoveryRequired 참조 위치

:::evidence key="expired-claim-versus-expired-execution" alt="코드베이스에서 RecoveryRequired 를 검색한 출력 10줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="RecoveryRequired 코드베이스 검색 — 10줄 · exit 0" zoom="true" :::

inbox도 같은 축을 쓴다

RECEIVED(takeover 가능)와 PROCESSING(→ DEAD, recovery-required)로 나눈다. 즉 "claim만 했다"와 "실행에 들어갔다"가 만료 시 다른 결론을 낳는다.

확인하지 못한 것

만료된 EXECUTING 이 실제로 조정 큐로 흘러가 사람이 처리하는 경로를 따라가지 않았다. 확인한 것은 저장소가 그 상태를 별도 결과로 답한다는 것이다.

컨테이너 레인 미실행