fix(lock): 락 timeout runbook이 있는 정보로 경합과 보유자를 찾게 한다
문제(round8 확인 리뷰 RR8-01-02):
- 락 timeout이 4xx carrier가 된 뒤로 어느 락이 막혔는지 서버 어디에도
남지 않는다. 그런데 runbook은 lock.acquisition metric에서 락 이름과
시간을 보라고 하고(metric은 outcome tag 하나뿐인 counter), 없는
integration_lock 테이블에서 보유자를 찾으라고 한다(테이블은 INT_LOCK,
LOCK_KEY는 key가 아니라 key의 UUID). 예외 Javadoc과 application-core
README는 메시지가 "서버 로그 전용"이라 적지만 그 메시지를 남기는
로그가 없다.
고른 방법(리뷰 권장안):
- runbook Symptoms·Diagnosis를 있는 정보로 다시 쓴다: 로그가 없다는 것,
경합 비율은 lock.acquisition{outcome} 비교(JDBC 락에만, 이름·시간
없음), INT_LOCK의 보유자 목록, 코드에서 아는 key의 보유자(key를
Spring Integration과 같은 name-based UUID로 계산하는 SQL).
- 두 SQL에 runbook-sql 표시를 달고 postgresqlDistributedLockIntegrationTest
가 runbook 파일에서 읽어 실 PostgreSQL에서 락을 잡은 채 돌린다(lane
입력에 runbook을 넣어 문서를 고치면 lane이 다시 돈다).
- 예외 Javadoc·README의 "서버 로그 전용"을 "클라이언트에 보내지 않고,
어느 로그에도 남지 않는다. 필요하면 호출자가 key()를 남긴다"로 고친다.
- 버린 안: 락 timeout에 WARN 한 줄(key digest, 대기 시간)을 남기기 —
로그 정책을 바꾸는 소유자 결정이고, 템플릿은 tryAcquire를 부르지 않는다.
위험·한계:
- runbook은 status: stub 그대로다. Action·Escalation 본문은 도메인을
고른 서비스가 쓴다.
- key가 UUID 문자열이면 Spring Integration은 그대로 쓰므로 계산 SQL이
맞지 않는다. runbook은 "코드에서 아는 key"만 말한다.
- OutboxRunbookSql을 그대로 쓴다. 그 이름을 바꾸는 수정(RR8-03-03)과
합칠 때 이 테스트의 참조도 함께 바뀌어야 한다.
검증(desktop, flock, --no-build-cache, 로그 ~/r9-g1-inbound-logs/):
- RED(문서의 주장을 단언한 임시 탐침, 기준 3eb3b067 + 탐침, 커밋 안 함,
트리 a675c244):
- "integration_lock 테이블에서 보유자를 찾는다": 락을 잡은 채
SELECT count(*) FROM integration_lock → postgresqlDistributedLock
IntegrationTest 7건 중 1건 실패, BadSqlGrammarException(relation
"integration_lock" does not exist). red/R6-jpa-table-claim.log
- "lock.acquisition metric에서 락 이름과 시간을 본다": timeout 뒤
outcome 밖의 tag가 있어야 한다 → MeteredDistributedLockTest 11건 중
1건 실패(tag 없음). red/R5-jpa-metric-claim.log
- GREEN(이 커밋 트리 fc5eae5a):
- :application-core:check :adapter:outbound:persistence-jpa:check rc=0,
test 1,089건 실패 0(skip 19는 application-core의 이전부터 것). 같은
worktree의 앞 실행(green/C1-check.log, 이 두 leaf의 입력이 같은 트리
acf42e98)으로 UP-TO-DATE. green2/C1-check.log
- :adapter:outbound:persistence-jpa:postgresqlDistributedLockIntegrationTest
rc=0, 8건(runbook의 두 SQL 블록을 파일에서 읽어 실행하는 새 테스트 2건
포함) 실패 0. green2/C2-lock-lane.log
- :app-bootstrap:documentContractTest rc=0, 67건(RunbookCoverageContract
Test 포함). green2/C3-doc-contract.log
Refs: docs/reviews/2026-11-03-rereview/README.md 19절 RR8-01-02, round8/01-transport-errors.md
This commit is contained in:
@@ -582,7 +582,10 @@ application 계층은 락 획득/해제 계약만 알고, 실제 구현은 adapt
|
||||
- `ApiErrorCarrier` 를 구현한다. 그래서 전송이 따로 처리기를 두지 않아도 web 은 409 +
|
||||
`Retry-After: 1`(레지스트리 값), GraphQL·gRPC 는 같은 코드로 답하고, 4xx 라 서버 로그를 남기지 않는다. 전에는
|
||||
carrier 가 아니어서 모든 전송이 500 `INTERNAL_ERROR`(재시도 불가)와 "unhandled" ERROR 로 답했다(재리뷰
|
||||
RR7-01-04). 진단용 `getMessage()`(key·waitTime 포함)는 서버 로그 전용이고 API 클라이언트에 전달하면 안 된다.
|
||||
RR7-01-04). `getMessage()`(key·waitTime 포함)는 클라이언트에 보내지 않고, 로그에도 남지 않는다. 4xx carrier 라
|
||||
어느 전송도 남기지 않고, 락 adapter 도 timeout 을 남기지 않는다. 어느 락이 막혔는지 기록이 필요하면 호출자가
|
||||
`key()` 를 직접 남긴다(엔티티 id 는 빼고). 운영 절차는 `docs/runbooks/lock-acquisition-timeout.md`
|
||||
(`lock.acquisition` metric, `INT_LOCK` 보유자 조회)다(재리뷰 RR8-01-02).
|
||||
|
||||
---
|
||||
|
||||
|
||||
+6
-1
@@ -11,7 +11,12 @@ import java.time.Duration;
|
||||
* through {@link ApiErrorCarrier}, the hook every inbound transport reads a code from: the web
|
||||
* adapter answers 409 with {@code Retry-After}, GraphQL and gRPC the same code, and none of them
|
||||
* logs it as an unhandled failure. Without the hook it was answered as a 500 {@code INTERNAL_ERROR}
|
||||
* (review 2026-11-06 RR7-01-04). {@link #getMessage()} is server-log-only. See README.
|
||||
* (review 2026-11-06 RR7-01-04).
|
||||
*
|
||||
* <p>{@link #getMessage()} names the key and the wait time. It is never sent to a client, and no
|
||||
* transport logs it either: a 4xx carrier is an answer, not an incident, so this timeout leaves no
|
||||
* server line, and the lock adapters do not log one. A caller that wants a record of which lock
|
||||
* timed out logs {@link #key()} itself, keeping entity ids out of the line. See README.
|
||||
*/
|
||||
public final class LockAcquisitionTimeoutException extends RuntimeException
|
||||
implements ApiErrorCarrier {
|
||||
|
||||
Reference in New Issue
Block a user