Skip to content

fix(backend): 停机预热任务回收异常隔离与超时兜底 - #77

Merged
fxbin merged 1 commit into
mainfrom
issue-73-shutdown-hardening
Sep 27, 2026
Merged

fxbin merged 1 commit into
mainfrom
issue-73-shutdown-hardening

Conversation

@fxbin

@fxbin fxbin commented Sep 27, 2026

Copy link
Copy Markdown
Owner

What & why

修复 #73 / 矩阵 D-10 的两处停机链中断点:

  1. _cache_warmup_task cancel 后仅 suppress(CancelledError)——任务若以非取消异常完成,await 再抛会跳过调度器停机、drain、DuckDB 关闭、engine.dispose 全部余下清理;
  2. jieba 预热 await 无超时,底层 to_thread 不可取消,词典加载卡住会挂死整个优雅停机。

修复:提取 _shutdown_prewarm_tasks 辅助函数——缓存任务异常只记 warning 不外抛(含已完成带异常的任务也必须 await 取回,避免静默丢失);jieba 走 wait_for 10s 超时兜底。

Refs #73(Parent #6)。Closes #73。

Area

  • backend

Verification

  • 新增 tests/test_shutdown_prewarm.py:异常不外抛且留痕 / jieba 超时不挂死(外层 wait_for 5s 反证)/ 正常与已取消路径静默
  • ruff check + ruff format --check 通过
  • 全量套件含本变更(d170df8 状态)exit 0

Verifier verdict

CI 门禁即机器 Verifier;停机隔离契约由独立单测钉死。

Checklist

  • Branch named issue-<number>-<short-slug> and PR links the issue
  • 无本地文件入库

@fxbin
fxbin merged commit 729dd36 into main Sep 27, 2026
5 checks passed
@fxbin
fxbin deleted the issue-73-shutdown-hardening branch September 27, 2026 14:36
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.

[P2][Lifecycle] 优雅停机链存在中断点:预热任务异常跳过后续清理、jieba await 无超时可挂死停机

1 participant