Skip to content

[Subtask]: D07 [baseline] Reuse the existing cron engine instead of a resident scheduler per SQL task #32285

Open

Description

@XuPeng-SH

Parent Issue

Parent issue: #32278

Detail of Subtask

Catalog ID: D07
Origin: B - Pre-existing in the 4.2 baseline and retained on main
Evidence level: Duplicate cost measured; no end-to-end regression claimed

4.2 versus main: provenance

4.2 already creates a separate cron.Cron for each SQL task. Main adds lifecycle protection but retains this structure. Ordinary cron uses one engine for multiple entries, and per-entry CRON_TZ already expresses timezone differences.

Design problem, impact, and existing responsibility

The HAKeeper leader's taskService maintains parallel discovery/scheduling infrastructure: SQL tasks reload every enabled definition every three seconds, and each job owns a scheduling goroutine plus stop/join handling. Definer and gate semantics do not by themselves establish the need for independent engines.

Acceptance criteria

  • Idle scheduling goroutines no longer grow by one per SQL task; retain necessary O(N) task definitions.
  • Preserve timezone, catch-up, update/suspend/delete, leader-change, shutdown, and durable trigger behavior without duplication.
  • Measure startup/idle CPU and memory at representative cardinality. Use minimal tasks for functional regressions rather than adding a 1,000-job UT fixture.

Describe implementation you've considered

Reuse existing cron/entry ownership while retaining SQL-task durable triggers, gates, definers, and overlap behavior. Measure full-definition polling at representative scale. Do not introduce a third scheduler framework.

Additional information

Existing investigation and validation limits

The production addCronTask/addSQLTask paths receive 1,000 non-immediate jobs using UTC and Asia/Shanghai. Scheduling goroutine increments are about 1 and 1,000. Local live-heap deltas are approximately 0.96-1.38MB and 2.94-3.03MB; these exclude some stack/RSS and SQL definitions and are not total-memory or end-to-end measurements.

main investigation snapshot: pkg/taskservice/sql_task_cron.go:165; pkg/taskservice/task_service_cron.go:44

4.2 baseline snapshot: pkg/taskservice/sql_task_cron.go:152

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]: D07 [base] 复用现有 cron 引擎,消除 SQL task 每任务一个常驻调度器[/-] [+][Subtask]: D07 [baseline] Reuse the existing cron engine instead of a resident scheduler per SQL task[/+] on Nov 5, 2026
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