fix: TKG build waits for face_traced.json to ensure face_track nodes are built
- Add check for face_traced.json existence before spawning TKG build - Prevents race condition where TKG reads Qdrant before trace_id is written - Logs clearly when waiting and when proceeding
This commit is contained in:
@@ -2102,12 +2102,29 @@ impl JobWorker {
|
|||||||
if tkg_done {
|
if tkg_done {
|
||||||
info!("✅ TKG already built for {}, skipping spawn", uuid);
|
info!("✅ TKG already built for {}, skipping spawn", uuid);
|
||||||
} else {
|
} else {
|
||||||
info!("📝 Prerequisites met for TKG Build. Starting graph construction...");
|
// Check if face_traced.json exists (store_traced_faces.py completed)
|
||||||
let db_clone = self.db.clone();
|
let traced_path = format!(
|
||||||
let redis_clone = self.redis.clone();
|
"{}{}.face_traced.json",
|
||||||
let uuid_clone = uuid.to_string();
|
crate::core::config::OUTPUT_DIR.as_str().trim_end_matches('/'),
|
||||||
let output_dir_clone = crate::core::config::OUTPUT_DIR.clone();
|
uuid
|
||||||
tokio::spawn(async move {
|
);
|
||||||
|
|
||||||
|
if !std::path::Path::new(&traced_path).exists() {
|
||||||
|
info!(
|
||||||
|
"⏳ TKG build waiting for face_traced.json: {} (file_uuid={})",
|
||||||
|
traced_path, uuid
|
||||||
|
);
|
||||||
|
// Don't spawn TKG yet, wait for next poll
|
||||||
|
} else {
|
||||||
|
info!(
|
||||||
|
"📝 Prerequisites met for TKG Build (face_traced.json exists): {}",
|
||||||
|
uuid
|
||||||
|
);
|
||||||
|
let db_clone = self.db.clone();
|
||||||
|
let redis_clone = self.redis.clone();
|
||||||
|
let uuid_clone = uuid.to_string();
|
||||||
|
let output_dir_clone = crate::core::config::OUTPUT_DIR.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
match crate::core::processor::tkg::build_tkg(
|
match crate::core::processor::tkg::build_tkg(
|
||||||
&db_clone,
|
&db_clone,
|
||||||
&uuid_clone,
|
&uuid_clone,
|
||||||
@@ -2191,6 +2208,7 @@ impl JobWorker {
|
|||||||
Err(e) => error!("❌ TKG build failed for {}: {}", uuid_clone, e),
|
Err(e) => error!("❌ TKG build failed for {}: {}", uuid_clone, e),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user