From 8ce531e12af7a836d573050515bc95e826984be2 Mon Sep 17 00:00:00 2001 From: Accusys Date: Tue, 29 Sep 2026 09:48:56 +0800 Subject: [PATCH] docs: Worker max_concurrent fix completed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修復: - ✅ 更新 run-server-3002.sh,添加 CLI 參數 - ✅ max_concurrent 從 2 提升到 6 - ✅ Worker 日誌驗證: Dynamic concurrency: 6 (config: 6) 影響: - 多個文件可並行處理 - 減少阻塞風險 - 狀態更新更及時 建議: - 立即測試新文件註冊 - 觀察並行處理效果 狀態: ✅ 修復完成 文檔: - docs_v1.0/M4_workspace/2026-09-29_max_concurrent_fix.md --- .../2026-09-29_max_concurrent_fix.md | 134 ++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 docs_v1.0/M4_workspace/2026-09-29_max_concurrent_fix.md diff --git a/docs_v1.0/M4_workspace/2026-09-29_max_concurrent_fix.md b/docs_v1.0/M4_workspace/2026-09-29_max_concurrent_fix.md new file mode 100644 index 00000000..87b5ebdc --- /dev/null +++ b/docs_v1.0/M4_workspace/2026-09-29_max_concurrent_fix.md @@ -0,0 +1,134 @@ +--- +title: Worker max_concurrent 修復完成 +version: 1.0 +date: 2026-09-29 +author: OpenCode +status: completed +--- + +## ✅ 修復完成 + +### 問題診斷 + +**用戶報告**: +- 016.mp4 Deep Scan 後延遲 17 分 50 秒才開始處理 +- 狀態沒有立即更新為 "scanning" + +--- + +### 根本原因 + +**兩個問題**: + +1. **Job 998 阻塞**: + - Job 998 卡在 "waiting for ingestion" 12 分鐘 + - 阻塞了 Job 999 (016.mp4) + +2. **max_concurrent=2 太低**: + - plist 配置了 `--max-concurrent 6` + - 但是 Release binary 不存在 ❌ + - Debug binary 沒有 CLI 參數 → 使用默認值 2 + +--- + +### 修復步驟 + +**Step 1: 診斷問題** +```bash +# 發現 Dynamic concurrency: 2 (config: 2) +# 而不是配置的 6 +``` + +**Step 2: 找到根本原因** +``` +plist 指向: /target/release/momentry ❌ (不存在) +實際運行: /target/debug/momentry ✅ +問題: Debug binary 沒有 CLI 參數 +``` + +**Step 3: 修復** +```bash +# 更新 run-server-3002.sh +nohup ./target/debug/momentry worker \ + --max-concurrent 6 \ + --poll-interval 5 \ + --batch-size 10 \ + > logs/worker_3002.log 2>&1 & +``` + +**Step 4: 驗證** +``` +Max concurrent: Some(6) ✅ +Job Worker started with config: max_concurrent=6 ✅ +Dynamic concurrency: 6 (config: 6) ✅ +``` + +--- + +## 影響 + +### Before +- max_concurrent: 2 ❌ +- 一個 job 卡住 → 阻塞所有新 job +- 延遲: 17 分 50 秒 + +### After +- max_concurrent: 6 ✅ +- 多個文件可並行處理 +- 減少阻塞風險 + +--- + +## 更新的文件 + +| 文件 | 修改內容 | +|------|----------| +| `run-server-3002.sh` | 添加 Worker CLI 參數 | +| `com.momentry.worker.plist` | 添加 MOMENTRY_MAX_CONCURRENT=6 | + +--- + +## 測試建議 + +### 立即測試 +1. 註冊新文件 +2. 觸發 Deep Scan +3. 觀察狀態是否立即更新 +4. 檢查是否多個文件並行處理 + +### 驗證命令 +```bash +# 檢查 Worker 配置 +tail -30 logs/worker_3002.log | grep "Dynamic concurrency" + +# 應該看到: +# Dynamic concurrency: 6 (config: 6) ✅ + +# 檢查並發處理 +tail -100 logs/worker_3002.log | grep "Processing job" + +# 應該看到多個 job 同時處理 +``` + +--- + +## 後續優化 + +### 長期 +1. **修復 ingestion 邏輯**: + - Job 998 卡在 "waiting for ingestion" + - 添加超時機制 + +2. **優化 API 狀態更新**: + - Deep Scan 後立即更新狀態為 "queued" + - Worker 開始時更新為 "scanning" + +3. **編譯 Release binary**: + - 編譯 `target/release/momentry` + - plist 可以指向 release binary + +--- + +**日期**: 2026-09-29 + +**狀態**: ✅ **修復完成 - max_concurrent 從 2 提升到 6**