fix: remove TKG guard to prevent deadlock
The TKG guard was checking if nodes exist before spawning TKG build. This caused a deadlock when: 1. TKG spawns (async) 2. ingestion_complete checks → false (nodes not yet created) 3. Returns Ok(false), job stays running 4. Next poll: guard checks nodes → no nodes yet (TKG still running) 5. Skips TKG → deadlock! Since build_tkg uses ON CONFLICT (idempotent), it's safe to call multiple times. Removed the guard to fix the deadlock.
This commit is contained in:
@@ -1839,20 +1839,8 @@ impl JobWorker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 🚀 P4 Trigger: TKG Build (Face + ASRX) → then Rule2 ingestion
|
// 🚀 P4 Trigger: TKG Build (Face + ASRX) → then Rule2 ingestion
|
||||||
|
// Note: build_tkg uses ON CONFLICT, so it's safe to call multiple times
|
||||||
if has_face && has_asrx {
|
if has_face && has_asrx {
|
||||||
// Guard: only spawn TKG if nodes don't exist yet
|
|
||||||
let tkg_nodes_table = schema::table_name("tkg_nodes");
|
|
||||||
let tkg_exists: bool = sqlx::query_scalar::<_, i32>(&format!(
|
|
||||||
"SELECT 1 FROM {tkg_nodes_table} WHERE file_uuid = $1 LIMIT 1"
|
|
||||||
))
|
|
||||||
.bind(uuid)
|
|
||||||
.fetch_optional(self.db.pool())
|
|
||||||
.await?
|
|
||||||
.unwrap_or(0) > 0;
|
|
||||||
|
|
||||||
if tkg_exists {
|
|
||||||
info!("✅ TKG already built for {}, skipping", uuid);
|
|
||||||
} else {
|
|
||||||
info!("📝 Prerequisites met for TKG Build. Starting graph construction...");
|
info!("📝 Prerequisites met for TKG Build. Starting graph construction...");
|
||||||
let db_clone = self.db.clone();
|
let db_clone = self.db.clone();
|
||||||
let redis_clone = self.redis.clone();
|
let redis_clone = self.redis.clone();
|
||||||
@@ -1887,7 +1875,6 @@ impl JobWorker {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if !Self::ingestion_complete(self.db.pool(), uuid, job_processors).await {
|
if !Self::ingestion_complete(self.db.pool(), uuid, job_processors).await {
|
||||||
info!(
|
info!(
|
||||||
|
|||||||
Reference in New Issue
Block a user