Skip to content

[Bug] CompleteSQLTaskRun accepts stale runner completion #25604

Closed

Description

@Ariznawlll

Summary

CompleteSQLTaskRun updates a task-run row using only run_id. A stale runner can therefore complete a run after that run has timed out/reallocated and overwrite the newer state.

Evidence

  • Commit: 7821d21c723372e45a8f65da3bbb896a157b1036
  • pkg/taskservice/mysql_task_storage.go:264-279 executes the update with WHERE run_id=? only.
  • pkg/taskservice/sql_task_executor.go:224-237 calls CompleteSQLTaskRun after execution, without a lease/attempt/version predicate.
  • The in-memory storage implementation has the same unconditional RunID overwrite behavior (pkg/taskservice/mem_task_storage.go:421-429).

Expected

Completion should be conditional on the runner's current lease/attempt/version, so a stale runner cannot overwrite a newer allocation or completion.

Please add a test that reallocates/times out a run while the old runner is still executing and verifies that the old completion is rejected.

Activity

  1. added
    kind/bug
    ai-light
    and removed
    ai-light
    on Jul 11, 2026
  2. added theissue type on Jul 11, 2026
  3. added this to the MO-202607 milestone on Jul 11, 2026
  4. added
    severity/s0
    and removed on Jul 12, 2026
  5. LeftHandCold commented on Jul 14, 2026

    @LeftHandCold
    Collaborator

    fixed

  6. Ariznawlll commented on Jul 14, 2026

    @Ariznawlll
    CollaboratorAuthor

    已在最新 main 上验证 SQL task stale completion fencing。

    验证版本

    • Commit:0977fc07c51067ce76b769c7853d7374cb2fccec
    • 验证时间:2026-07-14

    验证方法

    go test ./pkg/taskservice \
      -run '^TestCompleteSQLTaskRunRejectsReapedRun$' -count=1 -v

    测试先让旧 runner 的 task run 被 reaper 回收/重新分配,再模拟旧 runner 上报完成,检查 storage 是否会错误接受旧 run 的 completion。

    实际结果

    memory storage 与 refresh 路径均拒绝 stale/reaped run completion,两个子用例全部 PASS。

    结论

    当前 main 会根据 run identity/version 对完成请求进行 fencing,旧 runner 无法覆盖新 runner 的 task 状态。

    #25604 verification

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

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions