Skip to content

sql: event-driven scope scheduler - #29162

Closed
daviszhen wants to merge 35 commits into
matrixorigin:mainfrom
daviszhen:ready-task-scope-scheduler
Closed

daviszhen wants to merge 35 commits into
matrixorigin:mainfrom
daviszhen:ready-task-scope-scheduler

Conversation

@daviszhen

Copy link
Copy Markdown
Contributor

Summary

This PR adds the first compatibility-preserving phase of a query-local
ready-task/event-driven scheduler for Scope execution.

  • Root scopes now use a Compile-owned ready queue and workers instead of the
    process-wide ants default pool.
  • MergeRun child scopes and remote notification tasks use a Compile-owned
    dependency lane, with explicit task accounting and terminal draining.
  • Release, clear, and prepared Compile reset wait for scheduler quiescence
    before resetting/releasing Process and Scope owners.
  • Task labels, scheduler IDs, root completion, rejected submissions, and task
    panics are logged for startup/internal SQL debugging; panic errors cancel the
    query using MatrixOne's standard conversion.
  • Added scheduler design documentation and UT coverage for ready/dependency
    execution, single-worker parent/child deadlock avoidance, panic reporting,
    cancellation, and post-retirement submission.

The dependency lane intentionally remains query-owned and goroutine-backed for
this phase. Current MergeRun waits synchronously for children; putting those
children on a bounded ready queue would deadlock when a parent owns the last
worker. A later cooperative VM continuation contract can replace that lane
with fully bounded ready-task admission without changing the ownership API.

Validation

  • go test ./pkg/sql/compile -run '^TestScopeTaskScheduler' -count=20
  • go test -race ./pkg/sql/compile -run '^TestScopeTaskScheduler' -count=5
  • go test ./pkg/sql/compile -run '^(TestScopeTaskScheduler|TestCompileResetRejectsAPTopology|TestCompileClearResetsExecutionType|TestCompileReleaseClearsPlanSnapshotTransport)$' -count=5
  • remote notification focused tests
  • go vet ./pkg/sql/compile
  • git diff --check
  • make build-with-prebuilt-native
  • Docker single-node smoke from the built binary: fresh startup, DDL/DML,
    aggregation/CTAS, intentional missing-table error, and post-error query;
    container stayed running and retained rows.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

This branch had an error being deployed

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

Labels

do-not-merge/wip size/XL Denotes a PR that changes [1000, 1999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants