From a63a9c776fcbc7827b9d6cf2c8b885f839a75434 Mon Sep 17 00:00:00 2001 From: Accusys Date: Mon, 28 Sep 2026 21:31:20 +0800 Subject: [PATCH] fix: 020.mp4 trace_id issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 問題: - 020.mp4 deep scan 卡住 - Qdrant trace_id 全部為 -1 (210 個 faces) - TKG build 失敗,Worker 不斷重試 修復: - ✅ 更新 Qdrant trace_id (210 個) - ✅ 重新運行 rust_face_cluster - ✅ 生成正確的 face_cluster.json 結果: - ✅ Face clustering 成功 - ✅ 1 個 person 識別 - ✅ 212 個 faces 分配 - ✅ Deep scan 恢復正常 問題根源: - 與 test-3.mp4 相同:trace_id 沒有被正確更新到 Qdrant - 需要檢查 store_traced_faces.py 的更新邏輯 文檔: - docs_v1.0/M4_workspace/2026-09-28_020_mp4_trace_id_fix.md 狀態: ✅ 已修復 --- .../2026-09-28_020_mp4_trace_id_fix.md | 227 ++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100644 docs_v1.0/M4_workspace/2026-09-28_020_mp4_trace_id_fix.md diff --git a/docs_v1.0/M4_workspace/2026-09-28_020_mp4_trace_id_fix.md b/docs_v1.0/M4_workspace/2026-09-28_020_mp4_trace_id_fix.md new file mode 100644 index 00000000..c3c3ed08 --- /dev/null +++ b/docs_v1.0/M4_workspace/2026-09-28_020_mp4_trace_id_fix.md @@ -0,0 +1,227 @@ +--- +title: 020.mp4 Trace ID 修復報告 +version: 1.0 +date: 2026-09-28 +author: OpenCode +status: completed +--- + +## 問題描述 + +**文件**: 020.mp4 +**UUID**: b496a68800f90770aa7246c877f38985 +**狀態**: スキャン中 (Scanning) +**卡住原因**: Deep scan 沒動作 + +--- + +## 問題診斷 + +### 1. Worker 日誌顯示 + +``` +⚠️ TKG build proceeding with 210 faces (expected 212), 0 traces after 120s wait +[TKG-Qdrant] scroll returned 0 raw points +[TKG] No traced faces in Qdrant +``` + +### 2. Qdrant 數據 + +``` +Total points: 210 +Trace ID distribution: + trace_id=-1: 210 faces (100%) + +❌ 所有 trace_id 都是 -1 +``` + +### 3. 問題鏈 + +``` +trace_id = -1 + ↓ +Qdrant 中沒有有效 traces + ↓ +TKG build 失敗 + ↓ +Worker 不斷重試 + ↓ +Deep scan 卡住 +``` + +--- + +## 修復步驟 + +### Step 1: 檢查文件狀態 ✅ + +```bash +# 檢查 videos 表 +SELECT file_uuid, file_name, status, processing_status +FROM videos +WHERE file_uuid = 'b496a68800f90770aa7246c877f38985'; + +# 結果 +- Status: scanning +- POSE: running (但實際已完成) +- FACE_CLUSTER: completed +``` + +### Step 2: 檢查輸出文件 ✅ + +```bash +ls -lh /Users/accusys/momentry/output/b496a68800f90770aa7246c877f38985.*.json + +# 結果 +- face.json: 3.3M ✅ +- face_traced.json: 561K ✅ +- face_cluster.json: 116B ⚠️ (太小,可能是空的) +``` + +### Step 3: 更新 Qdrant trace_id ✅ + +```bash +# 使用之前的腳本更新 trace_id +python3 /tmp/update_all_trace_ids.py b496a68800f90770aa7246c877f38985 + +# 結果 +[INFO] Updated 210 trace_ids +``` + +### Step 4: 驗證 trace_id ✅ + +``` +Total points: 210 +Trace ID distribution: + trace_id=0: 38 faces + trace_id=1: 4 faces + trace_id=2: 4 faces + trace_id=3: 144 faces + ... + +✅ 有效 trace_id: 9 個 +總 faces: 210 +``` + +### Step 5: 重新運行 face_cluster ✅ + +```bash +# 使用修復後的 rust_face_cluster +rust_face_cluster --uuid b496a68800f90770aa7246c877f38985 + +# 結果 +[TRACE] Found 9 unique traces ✅ +[CLUSTER] Seed-leader detected 1 unique persons ✅ +Assigned person_id to 212 faces ✅ +``` + +### Step 6: 更新文件 ✅ + +```bash +# 替換舊的 face_cluster.json +mv face_cluster.json.tmp face_cluster.json + +# 驗證 +Status: has_faces ✅ +Clusters: 1 ✅ +Frames: 162 ✅ +``` + +--- + +## 最終結果 + +### ✅ 成功 + +**face_cluster.json**: +- Status: has_faces +- Clusters: 1 +- Frames: 162 +- Faces assigned: 212 + +**Qdrant _faces**: +- Total points: 210 +- Valid trace_ids: 9 +- All trace_id >= 0 + +--- + +## 問題根源 + +### 與 test-3.mp4 相同的問題 + +**trace_id = -1 的原因**: +1. Face detection 生成了 faces +2. Face tracing 生成了 trace_id +3. 但是 Qdrant 中的 trace_id 沒有被更新 + +**可能的問題點**: +- `store_traced_faces.py` 沒有正確更新 Qdrant +- 或者 Qdrant 的 trace_id 在某個時刻被重置為 -1 + +--- + +## 解決方案 + +### 已實施 + +1. **創建修復腳本** + - `/tmp/update_all_trace_ids.py` + - 使用 Qdrant `set_payload` API 更新 trace_id + +2. **修復 Rust binary** + - `rust_face_cluster.rs` 支持數組格式 + - 自動轉換 `frames` 數組為字典 + +--- + +### 需要長期改善 + +1. **修復 store_traced_faces.py** + - 確保正確更新 Qdrant trace_id + - 添加驗證和錯誤處理 + +2. **添加監控** + - trace_id = -1 的數量 + - Face clustering 成功率 + +3. **添加測試** + - 端到端測試 + - trace_id 更新測試 + +--- + +## 受影響的文件 + +### 需要檢查 + +**檢查所有文件的 trace_id 狀態**: + +```bash +# 列出所有 trace_id = -1 的文件 +curl -X POST -H "api-key: Test3200..." \ + http://127.0.0.1:6333/collections/_faces/points/scroll \ + -d '{"limit": 10000, "with_payload": true}' +``` + +--- + +## 總結 + +### ✅ 已完成 + +1. **診斷問題**: trace_id = -1 導致 TKG build 失敗 +2. **修復 trace_id**: 更新 210 個 trace_ids +3. **重新處理**: face_cluster 成功,生成正確的結果 + +### ⏳ 待處理 + +1. **檢查其他文件**: 是否有其他文件有相同問題 +2. **修復根本原因**: `store_traced_faces.py` 的更新邏輯 +3. **添加預防措施**: 監控和測試 + +--- + +**日期**: 2026-09-28 + +**狀態**: ✅ **已修復**