发布

  • [OPIK-6968] [BE] refactor: remove orphaned trace-thread scored_at write to cut lock contention (#7121)

    frostbyte_neo 发布于 2026-06-16 11:48:11 +00:00

    Online scoring stamped trace_threads.scored_at via TraceThreadService.setScoredAt, which acquired the per-project {projectId}-trace-threads-process lock on every scoring completion. The read that justified scored_at (dedup of closed-thread scoring against "WHERE scored_at IS NULL") was removed in #2719 when closure/scoring moved to a stream-on-close model; dedup is now structural (a thread is scored once, at the active->inactive transition). That left the write orphaned: scored_at is written but never read.

    Remove setScoredAt and all scored_at references from the threads domain, eliminating one of the producers contending for the single per-project lock. Behavior-neutral. Also narrows processTraceThreads to hold the lock only around the save (heavy processing now runs outside the lock).

    The scored_at ClickHouse column is intentionally retained (no migration) so a rolling deploy stays safe; it can be dropped in a follow-up once this is fully rolled out.

    Co-authored-by: Claude Opus 4.8 (1M context) noreply@anthropic.com

    下载附件