fix(search): improve async rebuild observability - #644
Conversation
Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
FenjuFu
left a comment
There was a problem hiding this comment.
LGTM — this closes exactly the observability gap I flagged on the #592 line. The MDC handling in the TaskDecorator is textbook-correct: it captures the caller's context at submit time, saves the worker thread's existing context before running, restores the caller context for the task, and in finally restores the worker's original context. That save-and-restore-the-worker step is the part people usually miss, and it's what prevents context bleed across pooled-thread reuse — nicely done.
The skillhub.search.rebuild.failure counter (one increment per failed skill, none on success) gives the metric-level visibility that was missing when rebuilds only produced ERROR logs. Not adding retry inside the shared executor is the right call — that would block the event pool; leaving persistent compensation as a separate extension keeps this focused. Tests cover single/batch-partial-failure/MDC-propagation/registry paths, and the reactor run is green.
|
维护者复核结论:本 PR 的 MDC TaskDecorator 和低基数失败计数本身实现正确,但范围仍把通用日志关联基础设施与搜索索引交付绑定在一起,且失败计数不能解决索引永久陈旧的问题。 因此采用以下替代方案:
#664 已在精确合入 |
修改内容
skillhubEventExecutor增加 MDC 上下文传播与执行后恢复。skillhub.search.rebuild.failure计数。修复原因
标签搜索索引重建已是异步任务,但执行线程读取不到原始请求 MDC;重建异常也只有 ERROR 日志,无法通过指标发现。
Closes #597
实现方式
验证
main基线:MDC 断言稳定得到null,两个指标断言均报告指标不存在。big-main的镜像远端隔离验证:83/83 通过。影响