From 532a2287c5b6690394c1e161f11ca68ce319135f Mon Sep 17 00:00:00 2001 From: Accusys Date: Thu, 19 Nov 2026 21:44:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Face=20Trace=20=E5=AE=8C=E6=88=90?= =?UTF-8?q?=E6=99=82=E5=90=8C=E6=AD=A5=20videos.processing=5Fstatus=20JSON?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 根因: FaceTrace 走獨立 pipeline(非 processor pool),當 face_traced.json 已存在而 skip spawn、或實際執行完成時,只更新 processor_results 表, 沒有更新 videos.processing_status 的 FACE_TRACE progress。 結果: 前端讀 processing_status 顯示 FACE_TRACE=running/0, 但 FACE_CLUSTER(走 processor pool)已 completed → 看起來違反依賴規則。 修復: 兩個完成路徑都補上 update_processor_progress('face_trace', completed): - skip 路徑(already done) - 實際執行成功路徑 手動修正 090.mp4 的 processing_status(先前 jsonb_set 路徑錯誤清空, 已重建完整 progress)。 --- src/worker/job_worker.rs | 43 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/worker/job_worker.rs b/src/worker/job_worker.rs index 1a4c3076..1d45eafa 100644 --- a/src/worker/job_worker.rs +++ b/src/worker/job_worker.rs @@ -4124,7 +4124,27 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> { if trace_complete { info!("✅ Face trace already done for {}, skipping spawn", uuid); - + + // Keep videos.processing_status JSON in sync: mark FACE_TRACE + // completed with full frame count. Without this, the UI shows + // FACE_TRACE stuck at running/0 while FACE_CLUSTER is completed + // (which looks like a broken dependency). + let tf = self + .db + .get_video_by_uuid(uuid) + .await + .ok() + .flatten() + .map(|v| v.total_frames as u64) + .unwrap_or(0); + if let Err(e) = self + .db + .update_processor_progress(uuid, "face_trace", tf, tf, "completed") + .await + { + warn!("[FACE_TRACE] failed to mark progress completed for {}: {}", uuid, e); + } + // ✅ Ensure processor_results record exists for dependency checks let mut success = false; for attempt in 1..=3 { @@ -4420,6 +4440,27 @@ async fn process_job(&self, job: crate::core::db::MonitorJob) -> Result<()> { &pp, ) .await; + + // Sync videos.processing_status JSON (UI source of truth) + let tf = db_clone + .get_video_by_uuid(&uuid_clone) + .await + .ok() + .flatten() + .map(|v| v.total_frames as u64) + .unwrap_or(0); + if let Err(e) = db_clone + .update_processor_progress( + &uuid_clone, + "face_trace", + tf, + tf, + "completed", + ) + .await + { + warn!("[FACE_TRACE] failed to mark progress completed for {}: {}", uuid_clone, e); + } } Err(e) => { error!(