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>
90 lines
3.8 KiB
Markdown
90 lines
3.8 KiB
Markdown
---
|
|
kind: CASE
|
|
slug: grpc-policy-f01
|
|
title: 스트림 승인의 경계가 동시성 아래에서 새고, caller별 맵이 줄지 않는다
|
|
topic: security-policy-enforcement
|
|
project: clean-architecture-backend-template
|
|
status: 게시 전
|
|
sourceRevision: 21234e38cdb9a926cbc92bb97a2aee2e4a7d2916
|
|
rootTreeNode: case:grpc-policy-f01
|
|
evidenceCapturedOn: 2026-09-01
|
|
assets:
|
|
- key: grpc-policy-f01
|
|
file: ../../../final/evidence/rendered/grpc-policy-f01.svg
|
|
- key: grpc-policy-f01-diagram
|
|
file: ../../../final/assets/diagrams/grpc-policy-f01.svg
|
|
evidence:
|
|
- ../../../final/evidence/raw/grpc-policy-f01.txt
|
|
source:
|
|
- 원본 분석 절은 analysis/grpc/grpc-policy.md#L184 이다.
|
|
module: grpc-policy
|
|
priority: P2
|
|
---
|
|
|
|
# 스트림 승인의 경계가 동시성 아래에서 새고, caller별 맵이 줄지 않는다
|
|
|
|
읽고 비교한 뒤 별도로 증가한다. 경계에 있는 N 개 스레드가 모두 통과한다.
|
|
|
|
## 문제
|
|
|
|
읽고 비교한 뒤 별도로 증가한다.
|
|
|
|
경계에 있는 N 개 스레드가 모두 통과한다.
|
|
|
|
## 결론
|
|
|
|
이 클래스의 javadoc 이 서술하는 실패 상황이 곧 고동시성이다 — "a client that reconnects on every error opens streams faster than the old ones close." 재접속 폭풍에서 경계가 가장 많이 샌다.
|
|
|
|
release 도 같은 형태라 음수로 갈 수 있다.
|
|
|
|
그리고 perCaller 에서 항목이 제거되지 않는다.
|
|
|
|
computeIfAbsent 가 호출자 지문마다 계수기를 만들고 release 는 값만 줄인다.
|
|
|
|
서로 다른 호출자 수만큼 맵이 자란다 — grpc-observability 의 GrpcMetricCardinalityPolicy 가 지표 태그에 대해 명시적으로 막는 것과 같은 종류의 증가이고, 여기에는 그 가드가 없다.
|
|
|
|
정본이 같은 리프에 있다 — GrpcRetryBudget.tryConsume 의 비교 후 교체 루프.
|
|
|
|
## 검증 환경
|
|
|
|
OpenJDK : 21.0.12 java -version 으로 확인
|
|
Gradle : 9.0.0 src/gradle/wrapper/gradle-wrapper.properties 의 distributionUrl 로 확인
|
|
확인 방식 : GrpcMetricCardinalityPolicy 참조 20건 검색과 승인 경로의 읽기·증가 원자성 확인
|
|
소스 수정 : x
|
|
|
|
## 재현 조건
|
|
|
|
원문은 analysis/grpc/grpc-policy.md#L184 에 있다.
|
|
|
|
## 본문
|
|
|
|
<!-- body:start -->
|
|
|
|
읽고 비교한 뒤 별도로 증가한다. 경계에 있는 N 개 스레드가 모두 통과한다.
|
|
|
|
## 두 값이 함께 커지는 조건
|
|
|
|
:::evidence key="grpc-policy-f01-diagram" alt="재접속 폭주가 같은 값 읽고 통과와 계수기 증가를 지나 경계 초과와 맵 증가로 이어진다" caption="두 값이 함께 커지는 조건" zoom="false"
|
|
:::
|
|
|
|
이 클래스의 javadoc 이 서술하는 실패 상황이 곧 고동시성이다 — "a client that reconnects on every error opens streams faster than the old ones close." 재접속 폭풍에서 경계가 가장 많이 샌다. `release` 도 같은 형태라 음수로 갈 수 있다.
|
|
|
|
## GrpcMetricCardinalityPolicy 참조 위치
|
|
|
|
:::evidence key="grpc-policy-f01" alt="코드베이스에서 GrpcMetricCardinalityPolicy 를 검색한 출력 20줄. 이 기록이 세는 참조가 그 출력에 그대로 보인다." caption="GrpcMetricCardinalityPolicy 코드베이스 검색 — 20줄 · exit 0" zoom="true"
|
|
:::
|
|
|
|
## perCaller 에서 항목이 제거되지 않는다
|
|
|
|
`computeIfAbsent` 가 호출자 지문마다 계수기를 만들고 `release` 는 값만 줄인다. 서로 다른 호출자 수만큼 맵이 자란다 — `grpc-observability` 의 `GrpcMetricCardinalityPolicy` 가 지표 태그에 대해 명시적으로 막는 것과 같은 종류의 증가이고, 여기에는 그 가드가 없다.
|
|
|
|
## 정본이 같은 리프에 있다
|
|
|
|
`GrpcRetryBudget.tryConsume` 의 비교 후 교체 루프.
|
|
|
|
## 확인하지 못한 것
|
|
|
|
동시 승인을 실행으로 재현하지 않았다. 원자성 분석과 JMM 으로 판정했고, 어떤 인터셉터도 실제 서버에 걸어 돌리지 않았다.
|
|
|
|
<!-- body:end -->
|