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>
63 lines
2.6 KiB
Markdown
63 lines
2.6 KiB
Markdown
---
|
|
kind: REFERENCE
|
|
slug: cas-tuple-in-the-where-clause
|
|
title: CAS 튜플을 where 절에 전부 반복하고 update count를 답으로 쓴다
|
|
topic: owner-safe-state-machines
|
|
project: clean-architecture-backend-template
|
|
status: 게시 전
|
|
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
|
|
rootTreeNode: reference:cas-tuple-in-the-where-clause
|
|
verifiedOn: # 이 기록은 이번 회차에 실행 확인을 하지 않았다
|
|
---
|
|
|
|
# CAS 튜플을 where 절에 전부 반복하고 update count를 답으로 쓴다
|
|
|
|
## 목적
|
|
|
|
행을 읽고 나서 갱신하는 형태를 없애, 리스가 만료된 작업자가 인계받은 작업자의 상태를 덮는 것을 막는다.
|
|
|
|
## 규칙
|
|
|
|
1. 소유자 튜플 전체를 where 절에 반복한다
|
|
스코프만으로 갱신하지 않는다. 소유자와 토큰과 시도와 상태 리비전을 전부 조건에 넣는다.
|
|
|
|
2. 갱신 건수가 답이다
|
|
한 건이면 이 소유자가 이 리비전에서 여전히 소유자였다는 뜻이고, 0 이면 다른 무언가가 레코드를 움직였다는 뜻이다.
|
|
|
|
3. 0 건은 예외가 아니라 정상 경로다
|
|
경합을 예외 처리로 다루면 그 경로가 테스트되지 않는다. 건수를 값으로 받아 호출자가 해석한다.
|
|
|
|
4. 전이마다 상태 리비전을 올린다
|
|
소유권만으로는 부족하다. 자기가 본 시점까지 맞아야 한다.
|
|
|
|
5. 같은 가드를 쓰는 문장을 한 자리에 모은다
|
|
흩어져 있으면 그중 하나가 조건을 짧게 쓰는 것을 막을 수 없다.
|
|
|
|
## 적용 조건
|
|
|
|
여러 작업자가 같은 행을 놓고 경합하는 모든 상태 기계
|
|
|
|
리스나 청구로 소유권을 표현하는 테이블
|
|
|
|
## 예외
|
|
|
|
단일 작업자만 접근하는 것이 구조적으로 보장되는 테이블은 대상이 아니다. 그 보장이 무엇인지 적혀 있어야 한다.
|
|
|
|
## 예시
|
|
|
|
멱등성 전이 문장들이 스코프와 토큰과 시도와 청구 연산과 상태 리비전을 전부 조건에 반복한다.
|
|
|
|
outbox 폴링 전달 어댑터의 완료 문장 셋이 같은 형태다.
|
|
|
|
네이티브 청구 문장이 JPA 버전 컬럼을 함께 올린다. 그러지 않으면 청구 이전에 로드된 엔티티의 플러시가 청구를 덮는다.
|
|
|
|
## 관계
|
|
|
|
- **CAS 튜플과 update count가 답이 되는 구조**
|
|
이 규칙이 나온 개념이다.
|
|
- **lease가 만료 시각만 기록하고 소유자를 기록하지 않아 terminal state가 되돌려졌다**
|
|
이 규칙이 없을 때의 결과다.
|
|
- **native claim이 Version을 올리지 않아 충돌을 보고하지 않는 낙관적 잠금이 됐다**
|
|
튜플을 반복해도 다른 잠금 장치와 어긋날 수 있다는 사례다.
|
|
|