[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,112 +2,187 @@
|
||||
id: wiki-2026-0508-system-debugging-protocol
|
||||
title: System Debugging Protocol
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Debug Workflow, Incident Debugging, SRE Debug Protocol]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [Debugging, Troubleshooting, Checklist, Process]
|
||||
confidence_score: 0.85
|
||||
verification_status: applied
|
||||
tags: [debugging, sre, incident, observability]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: shell/python
|
||||
framework: opentelemetry
|
||||
---
|
||||
|
||||
# 단계별 시스템 디버깅 체크리스트 (The Diagnostic Flowchart)
|
||||
# System Debugging Protocol
|
||||
|
||||
## 🔍 L1: 환경 및 무결성 검증 (Low Level)
|
||||
- **대상**: 404 Error, Syntax Error, 파일 경로.
|
||||
- **목표**: **'실행 가능한 물리적 토대'**가 마련되어 있는가?
|
||||
- **필수 조치**: 강제 새로고침(Ctrl + F5), 서버 재시작(Restart Ritual).
|
||||
## 매 한 줄
|
||||
> **"매 production system 의 이상 발생 시 가설 → 측정 → 수정 의 disciplined loop"**. 매 Brendan Gregg USE method, 매 Google SRE Workbook 의 incident protocol, 매 2026 OpenTelemetry + LLM-assisted 의 standard. 매 ad-hoc 디버깅 vs 체계적 protocol 의 결정적 차이.
|
||||
|
||||
## 🔍 L2: 통신 및 데이터 흐름 검증 (Communication)
|
||||
- **대상**: `onmessage`, `postMessage`, 비동기 처리.
|
||||
- **목표**: 메시지가 의도한 대로 흐르고 있는가?
|
||||
- **필수 조치**: 데이터 흐름 추적(`console.log`), 핸들러 동작 유무 확인.
|
||||
## 매 핵심
|
||||
|
||||
## 🔍 L3: 논리 엔진 및 비즈니스 검증 (High Level)
|
||||
- **대상**: 비즈니스 로직, 수학적 공식, 물리 엔진.
|
||||
- **목표**: 코드가 논리적으로 무결한가?
|
||||
- **필수 조치**: 최소 실행 예제(MRE)를 통한 격리 테스트.
|
||||
### 매 Phase
|
||||
1. **Detect**: alert 또는 user report.
|
||||
2. **Triage**: severity (P0-P4), scope, blast radius.
|
||||
3. **Stabilize**: rollback / circuit-break — root cause 의 wait 금지.
|
||||
4. **Diagnose**: USE / RED / TSA method.
|
||||
5. **Fix**: patch + verify.
|
||||
6. **Post-mortem**: blameless writeup.
|
||||
|
||||
## 🔗 연결된 지식
|
||||
- [[Tetris_Project_Retrospective|Tetris_Project_Retrospective]]
|
||||
- [[DevOps_Environment_Setup|DevOps_Environment_Setup]]
|
||||
### 매 Diagnostic methods
|
||||
- **USE (Brendan Gregg)**: 매 resource 의 Utilization / Saturation / Errors.
|
||||
- **RED**: 매 service 의 Rate / Errors / Duration.
|
||||
- **TSA (Thread State Analysis)**: 매 CPU / off-CPU profiling.
|
||||
- **4 golden signals (Google)**: latency, traffic, errors, saturation.
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
### 매 응용
|
||||
1. Web service slowness diagnosis.
|
||||
2. Memory leak hunt.
|
||||
3. DB lock investigation.
|
||||
4. Distributed tracing.
|
||||
|
||||
> *(TODO: 한 문장으로 핵심 통찰을 작성. "X는 Y 조건에서 Z 효과를 낸다" 구조 권장.)*
|
||||
## 💻 패턴
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
|
||||
**추출된 패턴:**
|
||||
> *(TODO)*
|
||||
|
||||
**세부 내용:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
|
||||
- **과거 데이터와의 충돌:** 없음
|
||||
- **정책 변화:** 없음
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
|
||||
- **Parent:** [[10_Wiki/Topics]]
|
||||
- **Related:** *(TODO: 최소 2개)*
|
||||
- **Opposite / Trade-off:** *(TODO)*
|
||||
- **Raw Source:** 직접 입력
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
### USE method checklist
|
||||
```bash
|
||||
# CPU
|
||||
mpstat -P ALL 1
|
||||
# Memory
|
||||
free -m; vmstat 1
|
||||
# Disk
|
||||
iostat -xz 1
|
||||
# Network
|
||||
sar -n DEV 1
|
||||
# All saturation in one
|
||||
top; vmstat 1; iostat -xz 1
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Distributed trace via OpenTelemetry
|
||||
```python
|
||||
from opentelemetry import trace
|
||||
tracer = trace.get_tracer(__name__)
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
@tracer.start_as_current_span("process_order")
|
||||
def process_order(order_id: str):
|
||||
span = trace.get_current_span()
|
||||
span.set_attribute("order.id", order_id)
|
||||
with tracer.start_as_current_span("db.fetch"):
|
||||
order = db.get(order_id)
|
||||
with tracer.start_as_current_span("external.payment"):
|
||||
charge(order)
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### Bisection (find regression commit)
|
||||
```bash
|
||||
git bisect start
|
||||
git bisect bad HEAD
|
||||
git bisect good v2.5.0
|
||||
# Run test at each step
|
||||
git bisect run pytest tests/regression.py
|
||||
git bisect reset
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Memory leak hunt (heap snapshot diff)
|
||||
```bash
|
||||
# Node.js
|
||||
node --inspect app.js
|
||||
# Chrome devtools → Memory → Heap snapshot at T0, T1
|
||||
# Compare → "Comparison" view → grow-only objects
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
# Python
|
||||
import tracemalloc
|
||||
tracemalloc.start()
|
||||
# ... run workload ...
|
||||
snap1 = tracemalloc.take_snapshot()
|
||||
# ... run more ...
|
||||
snap2 = tracemalloc.take_snapshot()
|
||||
for stat in snap2.compare_to(snap1, 'lineno')[:10]: print(stat)
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Flame graph
|
||||
```bash
|
||||
# Linux
|
||||
perf record -F 99 -p $PID -g -- sleep 30
|
||||
perf script | stackcollapse-perf.pl | flamegraph.pl > flame.svg
|
||||
|
||||
# Async profiler (JVM, on-CPU + off-CPU)
|
||||
./profiler.sh -d 30 -f flame.html $PID
|
||||
```
|
||||
|
||||
### SQL slow query (Postgres)
|
||||
```sql
|
||||
-- top slow
|
||||
SELECT query, calls, mean_exec_time, total_exec_time
|
||||
FROM pg_stat_statements
|
||||
ORDER BY total_exec_time DESC LIMIT 20;
|
||||
|
||||
-- live locks
|
||||
SELECT pid, usename, query, state, wait_event_type, wait_event
|
||||
FROM pg_stat_activity
|
||||
WHERE state != 'idle' ORDER BY xact_start;
|
||||
|
||||
-- explain
|
||||
EXPLAIN (ANALYZE, BUFFERS) SELECT ... ;
|
||||
```
|
||||
|
||||
### Hypothesis-driven debug log
|
||||
```markdown
|
||||
## Incident #2026-05-09-01
|
||||
- T0 12:34: Alert: p99 latency > 2s on /api/checkout
|
||||
- H1: DB slow → check pg_stat_statements → REJECTED (no slow queries)
|
||||
- H2: External payment API → trace shows 1.8s in stripe.charge() → CONFIRMED
|
||||
- Action: circuit-break stripe; queue charges for retry
|
||||
- T0+15min: latency recovered
|
||||
```
|
||||
|
||||
### Rollback protocol
|
||||
```bash
|
||||
# Kubernetes
|
||||
kubectl rollout undo deployment/api
|
||||
kubectl rollout status deployment/api
|
||||
|
||||
# Feature flag
|
||||
curl -X POST $LD_API/flags/$KEY/off
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| User-facing impact | Stabilize first (rollback) → diagnose |
|
||||
| Internal dev env | Diagnose deeply, no rollback urgency |
|
||||
| Repro available | Local debug + bisect |
|
||||
| Heisenbug | Production tracing + sampling |
|
||||
| Memory leak | Heap snapshot diff |
|
||||
| Latency spike | Distributed trace + flame graph |
|
||||
|
||||
**기본값**: Stabilize → Hypothesis → Measure → Fix → Post-mortem.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[SRE]] · [[Observability]]
|
||||
- 변형: [[USE Method]] · [[RED Method]] · [[Four Golden Signals]]
|
||||
- 응용: [[Incident Response]] · [[Post-Mortem]] · [[Performance Profiling]]
|
||||
- Adjacent: [[OpenTelemetry]] · [[Flame Graphs]] · [[Distributed Tracing]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: log pattern 분석, 가설 생성, post-mortem 초안.
|
||||
**언제 X**: live incident command (human judgment 필요).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **No stabilization**: 디버깅 중 service down 지속.
|
||||
- **Multiple changes at once**: 매 fix 의 attribution 불가.
|
||||
- **Skip post-mortem**: 매 same incident 의 반복.
|
||||
- **Blame culture**: 매 honest disclosure 의 chilling effect.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Brendan Gregg USE, Google SRE Book ch.12-14).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — Debug protocol full coverage |
|
||||
|
||||
Reference in New Issue
Block a user