Skip to content

[Subtask]: D03 [baseline] Make SQL task async/run completion consistent and resumable after partial failure #32281

Description

@XuPeng-SH

Parent Issue

Parent issue: #32278

Detail of Subtask

Catalog ID: D03
Origin: B - Pre-existing in the 4.2 baseline and retained on main
Evidence level: Reproduced behavioral defect

4.2 versus main: provenance

In both 4.2 and main, Complete independently commits async Completed before repairing sql_task_run. If the second step fails, retry is rejected by the first step's Running compare-and-swap predicate.

Design problem, impact, and existing responsibility

The outer task is completed while the inner run remains RUNNING. The runner treats InvalidTask as terminal and removes the task, leaving subsequent executions blocked by overlap. With no task timeout, recovery may wait until StartedAt + 24h; with a configured timeout, it uses timeout + 1min grace. Two lifecycle records lack a complete consistency/retry owner.

Acceptance criteria

  • Inject one run query/update error after async Completed; once storage recovers, retry completes the correct run and subsequent execution is admitted.
  • Cover uncertain commit acknowledgements, repeated completion, stale epochs/runners, and execution identity. Metadata repair does not repeat business side effects.
  • Keep task GC, timeout, and normal completion responsibilities coherent, including termination during shutdown.

Describe implementation you've considered

Reuse the existing TaskStorage transaction or idempotent-completion boundary so a retry can finish the remaining transition. Design it together with D02's execution-identity constraints. Do not rerun already-committed business SQL merely to repair metadata.

Additional information

Existing investigation and validation limits

TestAuditSQLTaskCompletionRepairRetry uses real memory storage and injects only one QuerySQLTaskRun error: async=Completed, run=RUNNING, retry=InvalidTask, next Acquire=overlap. Calling the original repair directly as a diagnostic control succeeds, proving the dependency has recovered. Normal and 100 focused race repetitions confirm the result.

main investigation snapshot: pkg/taskservice/task_service.go:185; pkg/taskservice/task_runner.go:610

4.2 baseline snapshot: pkg/taskservice/task_service.go:185

The named probes are local diagnostic overlays, not committed repository tests. Their names identify the investigation; they cannot be selected directly from an ordinary checkout. Implement the smallest maintained contract regressions and reuse relevant CI/validation proportionally. Temporary evidence commits are not required.

Activity

  1. self-assigned this
    on Nov 5, 2026
  2. added theissue type on Nov 5, 2026
  3. changed the title [-][Subtask]: D03 [base] 统一 SQL task 的 async/run 终态边界,使中途失败可重入完成[/-] [+][Subtask]: D03 [baseline] Make SQL task async/run completion consistent and resumable after partial failure[/+] on Nov 5, 2026
  4. added a commit that references this issue on Nov 11, 2026
    4df268e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions