Skip to content

[bugfix] Retain cancelled task ownership until transfers drain - #305

Open
XingLiu1 wants to merge 1 commit into
mainfrom
codex/task-lifecycle-20260924
Open

XingLiu1 wants to merge 1 commit into
mainfrom
codex/task-lifecycle-20260924

Conversation

@XingLiu1

Copy link
Copy Markdown
Collaborator

Cancelling a running task currently removes its graph ownership while transfers may still write to its blocks. Keep the task, graph mappings and plan pins until every transfer handle reports completion, then abort any still-detached staging. Completed per-writer publications retain the existing insert-after contract.

Reject cache reset while tasks are active. Replace active-task TTL eviction with explicit completion/response ownership, remove prefetch indexes only when their owning task is released, and discard heavy callback resources at graph completion.

Validation: 52 CPU/native-index task, cancellation and prefetch-publication tests passed, including successful/failed two-handle drains, early task-end completion, busy reset and replacement prefetch ownership. Applicable pre-commit hooks passed. DMA/GPU-model validation was not run for this change.

@linhu-nv

Copy link
Copy Markdown
Collaborator

#305 和 #306 我都 rebase 到了当前 main,一并说明。

main 已推进到 b77b125(#291),两个 PR 的 merge-base 还停在 738ddc1,导致 GitHub 把 #291 的 5500 行算成了你的改动。两个都需要 rebase 后 force-push。分支在 linhu-nv/FlexKV,commit author 保留为你:

git fetch https://github.com/linhu-nv/FlexKV rebase/task-lifecycle-onto-main
git push --force-with-lease origin FETCH_HEAD:codex/task-lifecycle-20260924

#306 同理:rebase/worker-startup-onto-main → codex/worker-startup-20260924

推完 diff 应该是 #305 → 2 文件 198 行,#306 → 5 文件 287 行。

#306 的冲突是纯机械的:2 处都在 check_completed_stores,#291 自己也做了同样的扁平化,我取了 main 侧。你的 _wait_kv_manager_ready 超时化没被抢先(main 的 connector.py:2386 至今还是无限循环),仍然有价值。

#305 有两处需要你看一下:

  1. _cancel_task — main 有个门控在 _runtime 上的 RUNNING 早返回,但你在更靠前的位置已无条件处理了 RUNNING,它变成不可达代码,我删掉了,以你的方案为准。
  2. reset_cache — 我没有照搬你的无条件 raise。保留了 main 的 coordinator 块(feat: add chunked prefetch policies with stop-and-drain lifecycle #291 的 stop-and-drain),把你的 raise 接在 legacy 尾部。coordinator 路径会 cancel 掉所有 task,走到尾部时 ongoing 自然为 0,不会二次触发。

多出的 commit a4fc013:这是两个改动合流才产生的 bug,单独看任一侧都不会触发。你新增的 self.tasks.clear() 使 #291 的 _terminal_tasks 条目全部悬空,而 _release_task 在 task_id not in self.tasks 时提前 return、不 pop 该表,于是 _reap_completed_tasks 的 while
terminal: 在 prefetch/runtime.py:84 的后台线程里死循环。修法是早返回路径也 pop,并在 reset_cache 里 clear。

另外 rebase 后你的普通 Dict 自动继承了 #291 的 reaper(10w 条/1800s),所以 task 泄漏的顾虑不成立了;但 reaper 只被 chunked 路径的 tick 驱动,非 chunked 路径还没有驱动点,要不要补由你判断。

顺带:#304 我会直接close——rebase 后 commit 被 git 自动丢弃,内容已被 #291 完整包含。

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.

2 participants