feat(lps): 작업 큐 엔진 — PostgreSQL 원자적 claim + lease + dead-letter
레퍼런스의 DB-큐 반면교사를 전부 뒤집는 큐 엔진을 구축한다. - 원자적 claim: FOR UPDATE SKIP LOCKED 서브쿼리 + 같은 UPDATE + RETURNING → 워커 다수여도 이중 할당 원천 불가(fetch/claim 미분리) - 모든 전이는 조건부 CAS(status/worker_id 가드) + RETURNING - 복구는 timeout 추측이 아닌 lease 만료 소유권 기반(reaper 회수) - 재시도 지수백오프 + max_attempts + dead-letter 를 큐에 내장(스크립트 난립 제거) - dedupe_key 부분 유니크로 활성 중복 차단, counts()로 관측(수동 psql 대체) - enums: JobStatus(PENDING/RUNNING/DONE/DEAD)·JobType(SEARCH/OUTBOX) - models: job 테이블(무FK·SMALLINT코드·TIMESTAMPTZ, claim/lease/dedupe 인덱스) - crud/job_crud: JobQueue(enqueue/claim/complete/fail/renew_lease/reap/counts) - tests: 동시 8워커 이중할당0·lease회수·재시도→dead·소유권가드 등 8건(실 lps_db) 부수: 포트 9400→9600 (negodata 9400 충돌 회피) Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
e27b73c018
commit
da9bd7750c
9 files changed
+339
-11
No files matched your search
+3
-3
@@ -17,7 +17,7 @@
|
||||
lps/
|
||||
├── web_main.py # 진입점
|
||||
├── requirements.txt / Dockerfile / .dockerignore
|
||||
├── run_local_server.sh # 로컬 실행(대화형), 포트 9400
|
||||
├── run_local_server.sh # 로컬 실행(대화형), 포트 9600
|
||||
├── pytest.ini / conftest.py
|
||||
├── config/
|
||||
│ ├── config_loader.py / config_models.py / server_configs.py
|
||||
@@ -38,7 +38,7 @@ lps/
|
||||
## 로컬 실행
|
||||
```bash
|
||||
cp config/config.local.toml.example config/config.local.toml # 값 채우기
|
||||
./run_local_server.sh # → http://localhost:9400/docs
|
||||
./run_local_server.sh # → http://localhost:9600/docs
|
||||
```
|
||||
|
||||
## 테스트
|
||||
@@ -47,7 +47,7 @@ python -m pytest # tests/ (기본 healthz 스모크)
|
||||
```
|
||||
|
||||
## 포트
|
||||
- backend 9300 / agent 9500 과 겹치지 않도록 **LPS 는 9400** 사용.
|
||||
- backend 9300 / negodata 9400 / agent 9500 과 겹치지 않도록 **LPS 는 9600** 사용.
|
||||
|
||||
## 새 도메인 추가 순서 (backend 컨벤션)
|
||||
1. `common/database/model/models.py` 에 테이블 정의(+ `DBType`)
|
||||
|
||||
Reference in new issue
Block a user