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:
Accusys
2026-08-10 01:42:34 +08:00
parent 65da4b451a
commit aa28bf93fb
3 changed files with 70 additions and 10 deletions
+19 -4
View File
@@ -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
);
}
}