fix: resolve merge silent failure by fixing upsert_trace_profile SQL and backfilling data
- Fixed upsert_trace_profile() SQL: changed trace_profiles.xxx to tp.xxx in ON CONFLICT DO UPDATE to fix invalid reference to FROM-clause entry error - Fixed cluster_agent.rs error handling: replaced 'let _ =' with proper error logging - Created migration script to backfill trace_profiles from tkg_nodes for existing files - Migration successfully inserted 98 missing trace_profiles records - Verified merge now works correctly: traces_merged > 0 instead of silent no-op This fixes both the rename 500 error and the merge silent failure, as they share the same root cause in upsert_trace_profile() SQL.
This commit is contained in:
@@ -259,21 +259,36 @@ pub async fn trigger_cluster_agent(
|
||||
};
|
||||
|
||||
if let Some(all_trace_ids) = trace_list {
|
||||
let mut success_count = 0;
|
||||
let mut error_count = 0;
|
||||
for tid in &all_trace_ids {
|
||||
let name = format!("Person_{}", tid);
|
||||
let _ = schema::upsert_trace_profile(
|
||||
match schema::upsert_trace_profile(
|
||||
state.db.pool(),
|
||||
&file_uuid,
|
||||
*tid as i32,
|
||||
&name,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
.await
|
||||
{
|
||||
Ok(_) => success_count += 1,
|
||||
Err(e) => {
|
||||
error_count += 1;
|
||||
tracing::error!(
|
||||
"[ClusterAgent] Failed to upsert trace profile for trace {}: {}",
|
||||
tid,
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
tracing::info!(
|
||||
"[ClusterAgent] Reset {} trace names to default for {}",
|
||||
"[ClusterAgent] Reset {} trace names to default for {} (success: {}, errors: {})",
|
||||
all_trace_ids.len(),
|
||||
file_uuid
|
||||
file_uuid,
|
||||
success_count,
|
||||
error_count
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,12 +58,12 @@ pub async fn upsert_trace_profile(
|
||||
LEFT JOIN {tp_table} tp ON tp.file_uuid = $1 AND tp.trace_id = $2 \
|
||||
ON CONFLICT (file_uuid, trace_id) \
|
||||
DO UPDATE SET name = EXCLUDED.name{update_props}, \
|
||||
start_frame = COALESCE(EXCLUDED.start_frame, trace_profiles.start_frame), \
|
||||
end_frame = COALESCE(EXCLUDED.end_frame, trace_profiles.end_frame), \
|
||||
frame_count = COALESCE(EXCLUDED.frame_count, trace_profiles.frame_count), \
|
||||
key_frame = COALESCE(EXCLUDED.key_frame, trace_profiles.key_frame), \
|
||||
key_face = COALESCE(EXCLUDED.key_face, trace_profiles.key_face), \
|
||||
avg_confidence = COALESCE(EXCLUDED.avg_confidence, trace_profiles.avg_confidence), \
|
||||
start_frame = COALESCE(EXCLUDED.start_frame, tp.start_frame), \
|
||||
end_frame = COALESCE(EXCLUDED.end_frame, tp.end_frame), \
|
||||
frame_count = COALESCE(EXCLUDED.frame_count, tp.frame_count), \
|
||||
key_frame = COALESCE(EXCLUDED.key_frame, tp.key_frame), \
|
||||
key_face = COALESCE(EXCLUDED.key_face, tp.key_face), \
|
||||
avg_confidence = COALESCE(EXCLUDED.avg_confidence, tp.avg_confidence), \
|
||||
updated_at = NOW()",
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user