Files
document-haness/docs/clean-architecture-backend-template/final/evidence/rendered/a05-f027-maximum-attempts-reclaim.svg
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

141 lines
12 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="1426" viewBox="0 0 1200 1426" role="img">
<title>terminal evidence</title>
<desc>Terminal-style rendering generated from retained command output. Sensitive-looking values are redacted in the visual asset.</desc>
<rect x="1" y="1" width="1198" height="1424" rx="14" fill="#0d1117" stroke="#30363d"/>
<rect x="1" y="1" width="1198" height="44" rx="14" fill="#161b22"/>
<rect x="1" y="30" width="1198" height="14" fill="#161b22"/>
<circle cx="24" cy="22" r="6" fill="#ff5f57"/>
<circle cx="44" cy="22" r="6" fill="#febc2e"/>
<circle cx="64" cy="22" r="6" fill="#28c840"/>
<text x="92" y="27" fill="#8b949e" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace">terminal evidence</text>
<text x="24" y="68" fill="#c9d1d9" font-size="15" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">$ set -e
mkdir -p /tmp/probe
CT=cleanup-reclaim-probe
docker rm -f &quot;$CT&quot; &gt;/dev/null 2&gt;&amp;1 || true
docker run -d --name &quot;$</tspan><tspan x="24" dy="22">CT&quot; --network &quot;container:workmachine&quot; \
-e POSTGRES_PASSWORD=probe -e POSTGRES_USER=probe -e POSTGRES_DB=probe \
pos</tspan><tspan x="24" dy="22">tgres:16-alpine -p 55432 &gt;/dev/null
for i in $(seq 1 40); do
docker inspect -f &#x27;{{.State.Running}}&#x27; &quot;$CT&quot; | grep -q tr</tspan><tspan x="24" dy="22">ue || { echo &#x27;컨테이너가 뜨지 않았다&#x27;; exit 1; }
docker exec &quot;$CT&quot; pg_isready -U probe -p 55432 &gt;/dev/null 2&gt;&amp;1 &amp;&amp; bre</tspan><tspan x="24" dy="22">ak
sleep 1
done
docker exec &quot;$CT&quot; psql -U probe -p 55432 -d probe -tAc &#x27;select version()&#x27; | cut -c1-24
M=adapter/outbo</tspan><tspan x="24" dy="22">und/persistence-jpa/src/main/resources/db/migration
for d in postgresql jpa/core jpa/fileserver; do
for f in $(ls &quot;$M/</tspan><tspan x="24" dy="22">$d&quot;/V*.sql | sort -V); do
docker exec -i &quot;$CT&quot; psql -U probe -p 55432 -d probe -q -v ON_ERROR_STOP=1 &lt; &quot;$f&quot; &gt;/dev/nu</tspan><tspan x="24" dy="22">ll 2&gt;&amp;1 || true
done
done
echo
echo &#x27;# 저장소의 청구 문장과 회수 문장을 아홉 번 반복한다.&#x27;
echo &#x27;# 시계 출처만 DB </tspan><tspan x="24" dy="22">로 바꿨다. 조건과 열은 저장소 질의 그대로다.&#x27;
echo &#x27;# 회수 대상을 고르는 조회는 태우지 않는다 — 그 조회에도 시도 한계</tspan><tspan x="24" dy="22">가 없음은 따로 확인했다.&#x27;
cat &gt; /tmp/probe/cp.sh &lt;&lt;&#x27;CPSH&#x27;
# 락파일의 한 구성에 실린 좌표 전부를 캐시 경로로 바꾼다. Grad</tspan><tspan x="24" dy="22">le 실행 없이 재현된다.
LOCK=${1:-adapter/outbound/persistence-jpa/gradle.lockfile}
CONF=${2:-postgresqlIntegrationTestRu</tspan><tspan x="24" dy="22">ntimeClasspath}
CACHE=/root/.gradle/caches/modules-2/files-2.1
cp=&quot;&quot;
while IFS= read -r line; do
coord=${line%%=*}; co</tspan><tspan x="24" dy="22">nfs=${line#*=}
case &quot;,$confs,&quot; in *&quot;,$CONF,&quot;*) ;; *) continue ;; esac
group=${coord%%:*}; rest=${coord#*:}; name=${r</tspan><tspan x="24" dy="22">est%%:*}; ver=${rest##*:}
jar=$(find &quot;$CACHE/$group/$name/$ver&quot; -name &#x27;*.jar&#x27; ! -name &#x27;*sources*&#x27; ! -name &#x27;*javadoc*&#x27; </tspan><tspan x="24" dy="22">2&gt;/dev/null | head -1)
[ -n &quot;$jar&quot; ] &amp;&amp; cp=&quot;$cp:$jar&quot;
done &lt; &lt;(grep -E &#x27;^[a-zA-Z0-9._-]+:[^=]+=&#x27; &quot;$LOCK&quot;)
echo &quot;${cp#:</tspan><tspan x="24" dy="22">}&quot;
CPSH
cat &gt; /tmp/probe/CleanupReclaimProbe.java &lt;&lt;&#x27;JAVA&#x27;
import java.sql.Connection;
import java.sql.DriverManager;
im</tspan><tspan x="24" dy="22">port java.sql.ResultSet;
import java.sql.Statement;
import java.util.UUID;
/** 청구와 리스 만료 회수를 아홉 번 반복한다</tspan><tspan x="24" dy="22">. 저장소의 두 질의를 그대로 쓴다. */
public class CleanupReclaimProbe {
private static final int MAXIMUM_ATTEMPTS = 8</tspan><tspan x="24" dy="22">;
private static final String CLAIM =
&quot;update fs_cleanup_item set status = &#x27;IN_PROGRESS&#x27;, claim_owner = ?, clai</tspan><tspan x="24" dy="22">m_token = ?,&quot;
+ &quot; lease_until = now() + interval &#x27;1 second&#x27;, claim_fence = claim_fence + 1,&quot;
+ &quot; upd</tspan><tspan x="24" dy="22">ated_at = now() where cleanup_id = ? and status in (&#x27;PENDING&#x27;, &#x27;FAILED&#x27;)&quot;;
private static final String RECLAIM =
</tspan><tspan x="24" dy="22"> &quot;update fs_cleanup_item set status = &#x27;FAILED&#x27;, attempt = attempt + 1,&quot;
+ &quot; next_attempt_at = now(), last_err</tspan><tspan x="24" dy="22">or_code = &#x27;CLAIM_LEASE_EXPIRED&#x27;,&quot;
+ &quot; claim_owner = null, claim_token = null, lease_until = null, updated_at =</tspan><tspan x="24" dy="22"> now()&quot;
+ &quot; where cleanup_id = ? and claim_token = ? and status = &#x27;IN_PROGRESS&#x27;&quot;;
public static void main(S</tspan><tspan x="24" dy="22">tring[] args) throws Exception {
try (Connection db = DriverManager.getConnection(
&quot;jdbc:postgresql://127.0.</tspan><tspan x="24" dy="22">0.1:55432/probe&quot;, &quot;probe&quot;, &quot;probe&quot;)) {
UUID id = UUID.randomUUID();
try (Statement s = db.createStatement())</tspan><tspan x="24" dy="22"> {
s.execute(&quot;delete from fs_cleanup_item&quot;);
}
try (var insert = db.prepareStatement(
&quot;ins</tspan><tspan x="24" dy="22">ert into fs_cleanup_item (cleanup_id, content_key, type, attempt, next_attempt_at,&quot;
+ &quot; status, claim_fenc</tspan><tspan x="24" dy="22">e, created_at, updated_at)&quot;
+ &quot; values (?, &#x27;k&#x27;, &#x27;ORPHAN_PHYSICAL_OBJECT&#x27;, 0, now(), &#x27;PENDING&#x27;, 0, now(), n</tspan><tspan x="24" dy="22">ow())&quot;)) {
insert.setObject(1, id);
insert.executeUpdate();
}
System.out.println(&quot;최대 시도 </tspan><tspan x="24" dy="22">횟수 상수 : &quot; + MAXIMUM_ATTEMPTS);
for (int round = 1; round &lt;= 9; round++) {
UUID token = UUID.randomUUI</tspan><tspan x="24" dy="22">D();
try (var claim = db.prepareStatement(CLAIM)) {
claim.setString(1, &quot;worker&quot;);
claim.setO</tspan><tspan x="24" dy="22">bject(2, token);
claim.setObject(3, id);
if (claim.executeUpdate() == 0) {
System.out.pr</tspan><tspan x="24" dy="22">intln(round + &quot; 회차: 청구 실패 — 더 이상 청구 가능한 상태가 아니다&quot;);
break;
}
}
</tspan><tspan x="24" dy="22"> try (var reclaim = db.prepareStatement(RECLAIM)) {
reclaim.setObject(1, id);
reclaim.setObject(2, t</tspan><tspan x="24" dy="22">oken);
reclaim.executeUpdate();
}
try (Statement s = db.createStatement();
ResultS</tspan><tspan x="24" dy="22">et r = s.executeQuery(
&quot;select attempt, status, last_error_code from fs_cleanup_item&quot;)) {
r.ne</tspan><tspan x="24" dy="22">xt();
System.out.printf(&quot;%d 회차 후: 시도 %d 상태 %s 마지막 오류 %s%n&quot;,
round, r.getInt(1), r.</tspan><tspan x="24" dy="22">getString(2), r.getString(3));
}
}
}
}
}
JAVA
CP=&quot;$(bash /tmp/probe/cp.sh adapter/outbound/persisten</tspan><tspan x="24" dy="22">ce-jpa/gradle.lockfile postgresqlIntegrationTestRuntimeClasspath)&quot;
javac -encoding UTF-8 -nowarn -cp &quot;$CP&quot; -d /tmp/probe</tspan><tspan x="24" dy="22"> /tmp/probe/CleanupReclaimProbe.java
java -Dstdout.encoding=UTF-8 -cp &quot;$CP:/tmp/probe&quot; CleanupReclaimProbe
docker rm -f</tspan><tspan x="24" dy="22"> &quot;$CT&quot; &gt;/dev/null 2&gt;&amp;1 || true</tspan></text>
<text x="24" y="992" fill="#8b949e" font-size="13" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">cwd: /shared/codebase/clean-architecture-backend-template/src</tspan></text>
<text x="24" y="1014" fill="#8b949e" font-size="13" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">time: 2026-09-02T05:43:41+00:00 · exit 0</tspan></text>
<line x1="24" y1="1028" x2="1176" y2="1028" stroke="#30363d"/>
<text x="24" y="1068" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">PostgreSQL 16.15 on x86_</tspan></text>
<text x="24" y="1090" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0"></tspan></text>
<text x="24" y="1112" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0"># 저장소의 청구 문장과 회수 문장을 아홉 번 반복한다.</tspan></text>
<text x="24" y="1134" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0"># 시계 출처만 DB 로 바꿨다. 조건과 열은 저장소 질의 그대로다.</tspan></text>
<text x="24" y="1156" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0"># 회수 대상을 고르는 조회는 태우지 않는다 — 그 조회에도 시도 한계가 없음은 따로 확인했다.</tspan></text>
<text x="24" y="1178" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">최대 시도 횟수 상수 : 8</tspan></text>
<text x="24" y="1200" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">1 회차 후: 시도 1 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
<text x="24" y="1222" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">2 회차 후: 시도 2 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
<text x="24" y="1244" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">3 회차 후: 시도 3 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
<text x="24" y="1266" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">4 회차 후: 시도 4 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
<text x="24" y="1288" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">5 회차 후: 시도 5 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
<text x="24" y="1310" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">6 회차 후: 시도 6 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
<text x="24" y="1332" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">7 회차 후: 시도 7 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
<text x="24" y="1354" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">8 회차 후: 시도 8 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
<text x="24" y="1376" fill="#e6edf3" font-size="14" font-family="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace" xml:space="preserve"><tspan x="24" dy="0">9 회차 후: 시도 9 상태 FAILED 마지막 오류 CLAIM_LEASE_EXPIRED</tspan></text>
</svg>