Files
document-haness/docs/clean-architecture-backend-template/tech-log-studio/owner-safe-state-machines/reference/reference-read-the-clock-after-the-lock.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

2.2 KiB

kind, slug, title, topic, project, status, sourceRevision, rootTreeNode, verifiedOn
kind slug title topic project status sourceRevision rootTreeNode verifiedOn
REFERENCE read-the-clock-after-the-lock 시간은 DB에서, 그리고 행을 잠근 다음에 읽는다 owner-safe-state-machines clean-architecture-backend-template 게시 전 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916 reference:read-the-clock-after-the-lock

시간은 DB에서, 그리고 행을 잠근 다음에 읽는다

목적

애플리케이션 시계로 리스 만료를 판단하거나 잠그기 전의 시각으로 판단해, 서로 다른 노드가 같은 행에 대해 다른 답을 내는 것을 막는다.

규칙

  1. 시각은 데이터베이스에서 읽는다 여러 노드의 시계는 서로 다르다. 리스 만료 판정의 기준 시각이 노드마다 다르면 두 노드가 동시에 소유자가 될 수 있다.

  2. 행을 잠근 다음에 읽는다 잠그기 전의 시각으로 판단하면 잠금을 기다리는 동안 리스가 만료될 수 있다.

  3. 판정과 갱신을 한 문장 안에 둔다 시각 비교를 where 절에 넣으면 판정과 갱신 사이에 시간이 흐르지 않는다.

  4. 만료 시각을 계산할 때도 같은 시계를 쓴다 읽은 시각과 쓰는 시각의 출처가 다르면 리스 길이가 의도와 달라진다.

적용 조건

리스와 청구와 예약처럼 시각이 소유권을 정하는 모든 상태 기계

여러 인스턴스가 같은 테이블을 폴링하는 구조

예외

단일 인스턴스만 접근하고 그 보장이 구조적인 경우는 애플리케이션 시계로 충분하다. 그 보장을 적어 둔다.

예시

청구 결정 트리가 데이터베이스에서 읽은 현재 시각으로 리스 만료를 판정한다.

리스를 발행 타임아웃보다 길게 두는 것은 확률을 낮출 뿐이고, GC 정지나 스케줄러 지연을 데이터 제약으로 바꾸지 않는다.

관계

  • CAS 튜플을 where 절에 전부 반복하고 update count를 답으로 쓴다 같은 문장 안에서 함께 쓰이는 규칙이다.
  • fenced lease — 만료 시각만으로는 부족한 이유 시각만으로 부족한 이유를 다룬 개념이다.