Skip to content

Fix/offline analysis mq - #611

Closed
VinCinx wants to merge 3 commits into
mainfrom
fix/offline-analysis-mq
Closed

Fix/offline analysis mq#611
VinCinx wants to merge 3 commits into
mainfrom
fix/offline-analysis-mq

Conversation

@VinCinx

@VinCinx VinCinx commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

What type of PR is this?

Check the PR title

  • This PR title match the format: [<type>][<scope>] <description>. For example: [fix][backend] flaky fix
  • The description of this PR title is user-oriented and clear enough for others to understand.
  • Add documentation if the current PR requires user awareness at the usage level.
  • This PR is written in English. PRs not in English will not be reviewed.

(Optional) Translate the PR title into Chinese

(Optional) More detailed description for this PR(en: English/zh: Chinese)

en:
zh(optional):

(Optional) Which issue(s) this PR fixes

VinCinx and others added 3 commits August 11, 2026 15:51
下游离线分析收到 item-complete(success) 后立即反查 standard eval output,
却常读到 running/空。根因是发送时机早于读侧就绪: 链路A(CompleteItemRun)
只写了 run_log(result_state=Logged) 就发 MQ, 而读侧三张表(turn_result /
evaluator_result_ref / item_result)要等链路B(scheduler daemon 扫 Logged →
RecordItemRunLogs)在下一个 tick 才写, 竞态窗口约一个 tick(BOE 实测 ~22.8s)。

将 item-complete(success) 唯一发送点从链路A 后移到链路B 的 recordEvalItemRunLogs:
在 RecordItemRunLogs 写完读侧三张表 + 置 result_state=Resulted 之后再发, 此刻
下游反查必读到就绪结果, 竞态消除。

- 删除链路A CompleteItemRun 里的 PublishItemComplete 发送块, 仅保留写 Logged
- ExptSchedulerImpl 注入 itemCompletePublisher + exptItemRefRepo
- recordEvalItemRunLogs 循环外按归属集(expt_item_ref)分组批量补 EvalSetItem
  (ItemKey / per-item 版本), 循环内 State==Success 守卫后组装并发送
- per-item DatasetVersionID 取 expt_item_ref.EvalSetVersionID(多集非主集也正确),
  不用 ExptEvalItem.EvalSetVersionID(主集硬编码)
- 抽 buildItemCompleteEventFromScheduler 复用 buildItemCompleteEvent 语义, 单一实现
- 幂等靠 result_state Logged→Resulted 状态位; 下游按 (expt_id,expt_run_id,item_id) 去重
- 发送失败只 CtxWarn 不阻断

Co-Authored-By: Claude Opus 4.8 <[email protected]>
链路B item-complete 发送不可靠: 发失败只告警且 result_state 已置 Resulted 终态,
tick 下轮扫描(result_state=Logged)不再命中 → 消息永久丢失。

改为:
- 新增终态 ExptItemResultStateSent; Resulted 降级为"读侧已写待发送"
- tick 扫描条件纳入 Resulted(Logged→Logged|Resulted), 使待发送 item 下轮被重扫
- 发送成功才 MarkItemResultSent 翻 Sent; 失败留 Resulted 下轮重发
- 非成功行/开源 nil publisher 直接翻 Sent; 卡 Resulted 超 30min 强制翻 Sent + 告警
- 不重复写表: 靠 RecordItemRunLogs 既有幂等门(!=Logged 短路), 统计不重复累加
- sendItemComplete 成功打印完整 event JSON(便于验证与排障)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
- Test_buildItemCompleteEvent_LinkAB_Equivalence: 钉死链路A/B组装一致契约
- Test_resolveItemCompleteMeta: 单集/多集/ref缺失/主集缺失/MGet失败/BatchGet失败 (0→100%)
- Test_MarkItemResultSent (0→100%)
- Test_findEvalSetForItem: nil/单集/多集命中不命中 (50→100%)
- Test_sendItemComplete_nilMeta: meta 缺失分支 (→100%)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@VinCinx VinCinx closed this Aug 11, 2026
@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...on/domain/service/expt_run_scheduler_event_impl.go 95.45% 2 Missing and 2 partials ⚠️

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #611      +/-   ##
==========================================
+ Coverage   78.17%   78.21%   +0.04%     
==========================================
  Files         691      691              
  Lines       84608    84699      +91     
==========================================
+ Hits        66139    66248     +109     
+ Misses      14538    14524      -14     
+ Partials     3931     3927       -4     
Flag Coverage Δ
unittests 78.21% <96.29%> (+0.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ckend/modules/evaluation/domain/entity/expt_run.go 98.64% <ø> (ø)
...ules/evaluation/domain/service/expt_result_impl.go 72.69% <100.00%> (+0.05%) ⬆️
...es/evaluation/domain/service/expt_run_item_impl.go 79.87% <100.00%> (+6.30%) ⬆️
...ion/domain/service/expt_run_scheduler_mode_impl.go 85.27% <100.00%> (ø)
...on/domain/service/expt_run_scheduler_event_impl.go 82.04% <95.45%> (+2.27%) ⬆️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 13d4766...5da4fc1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant