Skip to content

dxf: add StepPrepared prepare-mode transition in scheduler framework - #68581

Merged
ti-chi-bot[bot] merged 18 commits into
pingcap:masterfrom
D3Hunter:import-async-prepare-dxf-part
May 26, 2026
Merged

ti-chi-bot[bot] merged 18 commits into
pingcap:masterfrom
D3Hunter:import-async-prepare-dxf-part

Conversation

@D3Hunter

@D3Hunter D3Hunter commented May 22, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #68580

Problem Summary:
IMPORT INTO nextgen prepare flow needs a framework-level marker-step transition (init -> prepared) so prepare work can be completed and persisted before normal business-step scheduling.

What changed and how does it work?

  1. Add framework marker step StepPrepared and map it back to business StepInit in next-step resolution.
  2. Add prepare_mode (disabled/required) to proto.ExtraParams with backward-compatible JSON behavior.
  3. Extend scheduler pending flow:
    • when prepare_mode=required and step is init, call OnPrepare.
    • persist prepare outputs through a new storage transition API.
    • move task step to prepared on successful CAS transition.
  4. Add SwitchTaskStepAfterPrepare storage API to persist prepare outputs atomically for pending + init -> pending + prepared.
  5. Add/extend unit and integration-oriented framework tests for prepare-mode flow, StepPrepared mapping, and prepare transition persistence.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Unit test commands:

go test ./pkg/dxf/framework/proto -tags=intest,deadlock
go test ./pkg/dxf/framework/scheduler -tags=intest,deadlock -run 'TestSchedulerMaintainTaskFields|TestSchedulerOnNextStage'
go test ./pkg/dxf/framework/storage -tags=intest,deadlock -run '^TestSwitchTaskStep$'

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

None

Summary by CodeRabbit

  • New Features

    • Optional task prepare mode (disabled by default) with a new "prepared" step; prepare hook can modify task metadata, required runtime slots, and max node count; prepare completion is persisted atomically.
    • Scheduler logs now include prepare-mode information.
  • Behavior Changes

    • Target-step validation now excludes framework-only steps (only business steps accepted).
    • Extra parameters are merged on update (partial updates preserved).
  • Tests

    • Expanded coverage for prepare-mode flows, persistence, validation, and failure/retry handling.

Review Change Stack

@ti-chi-bot ti-chi-bot Bot added the release-note-none Denotes a PR that doesn't merit a release note. label May 22, 2026
@pantheon-ai

pantheon-ai Bot commented May 22, 2026 •

Copy link
Copy Markdown

@D3Hunter I've received your pull request and will start the review. I'll conduct a thorough review covering code quality, potential issues, and implementation details.

⏳ This process typically takes 10-30 minutes depending on the complexity of the changes.

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label May 22, 2026
@tiprow

tiprow Bot commented May 22, 2026

Copy link
Copy Markdown

Hi @D3Hunter. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@coderabbitai

coderabbitai Bot commented May 22, 2026 •

Copy link
Copy Markdown

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds PrepareMode and StepPrepared, Extension.OnPrepare and TaskManager.SwitchTaskStepAfterPrepare, scheduler changes to run OnPrepare and atomically persist StepPrepared and prepared metadata, storage change to merge extra_params, and tests/mocks validating prepare-mode and runtime-slot behavior.

Changes

Prepare-Mode Task Lifecycle

Layer / File(s) Summary
Data schema: prepare-mode enum and prepared step
pkg/dxf/framework/proto/task.go, pkg/dxf/framework/proto/step.go
Adds PrepareMode enum with PrepareModeDisabled/Required, PrepareMode.String(), ExtraParams.PrepareMode JSON field, and StepPrepared marker; adds IsValidBusinessStep helper.
Proto tests for new enums/steps
pkg/dxf/framework/proto/step_test.go, pkg/dxf/framework/proto/task_test.go
Unit tests verifying Step2Str(..., StepPrepared), IsValidStep/IsValidBusinessStep, PrepareMode integer/string values and ExtraParams JSON marshal/unmarshal behavior.
Scheduler interfaces: prepare hooks and step-switch API
pkg/dxf/framework/scheduler/interface.go
Adds Extension.OnPrepare(ctx, handle, task) error and TaskManager.SwitchTaskStepAfterPrepare(ctx, task) (bool, error) with docs restricting mutable fields during prepare.
Generated mocks for prepare APIs
pkg/dxf/framework/mock/scheduler_mock.go, pkg/dxf/framework/scheduler/mock/scheduler_mock.go
Adds GoMock methods and recorders for OnPrepare and SwitchTaskStepAfterPrepare.
Scheduler prepare-phase execution
pkg/dxf/framework/scheduler/scheduler.go
Adds BaseScheduler.OnPrepare default, extends logs to include prepare-mode, and updates onPending to call OnPrepare then SwitchTaskStepAfterPrepare, persist StepPrepared on success, then continue next-step flow.
Storage persistence: atomic step transition & extra_params merge
pkg/dxf/framework/storage/task_table.go
Implements SwitchTaskStepAfterPrepare as transactional CAS UPDATE to persist StepPrepared, meta, concurrency, max_node_count; changes UpdateTaskExtraParams to use JSON_MERGE_PATCH with COALESCE.
Storage tests for prepare transition
pkg/dxf/framework/storage/table_test.go, pkg/dxf/framework/storage/task_state_test.go
Tests SwitchTaskStepAfterPrepare success and CAS semantics; tests UpdateTaskExtraParams preserves existing fields across partial updates.
Scheduler tests for prepare-phase behavior
pkg/dxf/framework/scheduler/scheduler_nokit_test.go
Adds subtests exercising onPending prepare error/success paths, OnPrepare mutations, and conditional step switch behavior.
Integration tests: runtime slots & prepare-mode scenarios
pkg/dxf/framework/integrationtests/framework_test.go
Refactors TestMaxRuntimeSlots into subtests: runtime-slot limiting, prepare-mode-required verifying OnPrepare and metadata propagation, and prepare-mode-disabled backward-compat check.
Handler validation change
pkg/server/handler/tikvhandler/dxf.go
Validates requested target steps with proto.IsValidBusinessStep instead of proto.IsValidStep.

Sequence Diagram(s):

sequenceDiagram
  participant Scheduler
  participant Extension
  participant TaskManager
  participant Storage
  Scheduler->>Extension: OnPrepare(ctx, handle, task) -- compute Meta/RequiredSlots/MaxNodeCount
  Extension-->>Scheduler: nil / error
  Scheduler->>TaskManager: SwitchTaskStepAfterPrepare(ctx, preparedTask)
  TaskManager->>Storage: UPDATE mysql.tidb_global_task (CAS Init→Prepared) with meta/concurrency/max_node_count
  Storage-->>TaskManager: (switched bool, err)
  TaskManager-->>Scheduler: (switched bool, err)
  alt switched == true
    Scheduler->>Scheduler: set task.Step = StepPrepared and continue to GetNextStep
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Suggested labels

sig/planner, ok-to-test, approved, lgtm

Suggested reviewers

  • joechenrh
  • GMHDBJD

Poem

🐰 A hop, a prep, a careful tweak,
Init waits patient while plans we seek.
Meta stitched and slots aligned,
Prepared and ready — then it’s time.
Off it hops to finish the find.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 37.50% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding StepPrepared prepare-mode transition in the scheduler framework.
Linked Issues check ✅ Passed All code changes directly implement the objectives from #68580: StepPrepared marker, prepare_mode flag, OnPrepare hook, SwitchTaskStepAfterPrepare storage API, and comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are within scope of the PR objectives: framework changes for prepare-mode flow (new step, enum, interfaces, storage), mock generation, and test coverage for the new transition mechanics.
Description check ✅ Passed PR description covers problem statement, changes, test checklist, and follows template structure with detailed problem/solution context.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@pkg/dxf/framework/scheduler/scheduler_nokit_test.go`:
- Around line 521-523: The local variable taskPreparedByOtherOwner is assigned
but never used in scheduler_nokit_test.go, causing a compile error; remove the
declaration and its assignments (the three lines creating
taskPreparedByOtherOwner, setting Step and Meta) or, if the intent was to assert
behavior for a prepared task, actually use taskPreparedByOtherOwner in the test
(e.g., pass it to the function under test or add assertions) so it is
referenced. Ensure no other code depends on that variable before removal.

In `@pkg/dxf/framework/storage/task_table.go`:
- Around line 875-883: The CAS update that moves a task to proto.StepPrepared
must also persist extra_params so OnPrepare edits aren't lost; update the SQL
that updates mysql.tidb_global_task to include extra_params = %? in the SET list
and add task.ExtraParams to the parameter list (alongside proto.StepPrepared,
task.Meta, task.RequiredSlots, task.MaxNodeCount) before the task.ID/expected
state args used in the where clause so the prepare-step write saves ExtraParams
as well.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bc18dfb9-ee54-4ae1-921e-a8a0ac4fd19e

📥 Commits

Reviewing files that changed from the base of the PR and between 26a4494 and 59ff180.

📒 Files selected for processing (12)
  • pkg/dxf/framework/integrationtests/framework_test.go
  • pkg/dxf/framework/mock/scheduler_mock.go
  • pkg/dxf/framework/proto/step.go
  • pkg/dxf/framework/proto/step_test.go
  • pkg/dxf/framework/proto/task.go
  • pkg/dxf/framework/proto/task_test.go
  • pkg/dxf/framework/scheduler/interface.go
  • pkg/dxf/framework/scheduler/mock/scheduler_mock.go
  • pkg/dxf/framework/scheduler/scheduler.go
  • pkg/dxf/framework/scheduler/scheduler_nokit_test.go
  • pkg/dxf/framework/storage/table_test.go
  • pkg/dxf/framework/storage/task_table.go

Comment thread pkg/dxf/framework/scheduler/scheduler_nokit_test.go Outdated
Comment thread pkg/dxf/framework/storage/task_table.go
@codecov

codecov Bot commented May 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.3136%. Comparing base (e53c50c) to head (f707c95).
⚠️ Report is 14 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #68581        +/-   ##
================================================
- Coverage   76.3752%   75.3136%   -1.0617%     
================================================
  Files          2039       2021        -18     
  Lines        562884     566944      +4060     
================================================
- Hits         429904     426986      -2918     
- Misses       132062     139956      +7894     
+ Partials        918          2       -916     
Flag Coverage Δ
integration 41.3590% <0.0000%> (+1.5879%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 60.4679% <ø> (ø)
parser ∅ <ø> (∅)
br 48.9428% <ø> (-13.9773%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ingress-bot

Copy link
Copy Markdown

🔍 Starting code review for this PR...

@ingress-bot ingress-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This review was generated by AI and should be verified by a human reviewer.
Manual follow-up is recommended before merge.

Summary

  • Total findings: 13
  • Inline comments: 12
  • Summary-only findings (no inline anchor): 0
Findings (highest risk first)

⚠️ [Major] (8)

  1. FrameworkStep2BusinessStep name and doc overstate what the helper actually returns (pkg/dxf/framework/proto/step.go:199, pkg/dxf/framework/proto/step_test.go:60)
  2. Scheduler-internal step translation is exported from the shared proto package (pkg/dxf/framework/proto/step.go:203, pkg/dxf/framework/scheduler/scheduler.go:499)
  3. New prepare-mode flag is dropped by max-runtime-slots updates (pkg/dxf/framework/proto/task.go:116, pkg/server/handler/tikvhandler/dxf.go:432, pkg/dxf/framework/storage/task_table.go:1187)
  4. OnPrepare contract omits reentry/idempotency semantics for CAS race path (pkg/dxf/framework/scheduler/interface.go:156, pkg/dxf/framework/scheduler/scheduler.go:393, pkg/dxf/framework/storage/task_table.go:866)
  5. Prepare-phase mutation contract is comment-only and split across interface and SQL (pkg/dxf/framework/scheduler/interface.go:163, pkg/dxf/framework/storage/task_table.go:875, pkg/dxf/framework/scheduler/scheduler.go:405)
  6. Non-retryable OnPrepare failures are retried forever instead of triggering task failure handling (pkg/dxf/framework/scheduler/scheduler.go:394, pkg/dxf/framework/scheduler/scheduler.go:285)
  7. Prepare-mode retries re-execute OnPrepare and break replay parity (pkg/dxf/framework/scheduler/scheduler.go:389, pkg/dxf/framework/scheduler/scheduler.go:285, pkg/dxf/framework/storage/task_table.go:868)
  8. Persisting StepPrepared introduces an unguarded downgrade incompatibility (pkg/dxf/framework/storage/task_table.go:876, pkg/dxf/framework/scheduler/scheduler.go:499, pkg/dxf/example/scheduler.go:94, pkg/dxf/importinto/scheduler.go:517)

🟡 [Minor] (5)

  1. Step lifecycle comments are stale after introducing StepPrepared (pkg/dxf/framework/proto/step.go:27, pkg/dxf/framework/storage/task_table.go:866, pkg/dxf/framework/scheduler/scheduler.go:499)
  2. Framework-only StepPrepared is now accepted as an external target step (pkg/dxf/framework/proto/step.go:48, pkg/dxf/framework/proto/step.go:63, pkg/server/handler/tikvhandler/dxf.go:426)
  3. SwitchTaskStepAfterPrepare contract text is broader than what persistence actually does (pkg/dxf/framework/scheduler/interface.go:86, pkg/dxf/framework/storage/task_table.go:875)
  4. Prepare success path adds a fixed extra scheduler interval before subtask planning (pkg/dxf/framework/scheduler/scheduler.go:406, pkg/dxf/framework/scheduler/scheduler.go:55)
  5. Prepare transition duplicates task-state SQL transition logic instead of reusing existing transition helper (pkg/dxf/framework/storage/task_table.go:868, pkg/dxf/framework/storage/task_table.go:893)

Comment thread pkg/dxf/framework/proto/step.go Outdated
Comment thread pkg/dxf/framework/proto/step.go Outdated
Comment thread pkg/dxf/framework/proto/task.go
Comment thread pkg/dxf/framework/scheduler/interface.go
Comment thread pkg/dxf/framework/scheduler/interface.go
Comment thread pkg/dxf/framework/proto/step.go
Comment thread pkg/dxf/framework/proto/step.go
Comment thread pkg/dxf/framework/scheduler/interface.go Outdated
Comment thread pkg/dxf/framework/scheduler/scheduler.go Outdated

// SwitchTaskStepAfterPrepare atomically persists prepare completion from
// pending+init to pending+prepared.
func (mgr *TaskManager) SwitchTaskStepAfterPrepare(ctx context.Context, task *proto.Task) (bool, error) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 [Minor] Prepare transition duplicates task-state SQL transition logic instead of reusing existing transition helper

Impact
This PR introduces a second hand-written CAS update path for mysql.tidb_global_task transitions. Keeping transition SQL in parallel implementations increases drift pressure on transition invariants and forces future transition changes to be duplicated across two code paths.

Scope

  • pkg/dxf/framework/storage/task_table.go:868 — TaskManager.SwitchTaskStepAfterPrepare
  • pkg/dxf/framework/storage/task_table.go:893 — updateTaskStateStep

Evidence
SwitchTaskStepAfterPrepare adds a separate update mysql.tidb_global_task ... where id/state/step statement, while updateTaskStateStep already owns the core task state-step CAS transition update. Both functions now maintain overlapping transition responsibilities with different hard-coded field sets.

Change request
Refactor transition persistence so the prepare path reuses a shared transition primitive with explicit per-transition field options, rather than introducing another standalone SQL transition body. Keep one authoritative transition helper for CAS predicates and shared update semantics.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/dxf/framework/scheduler/scheduler.go (1)

398-406: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Reload the task after a successful prepare CAS.

This path only patches task.Step locally. If SwitchTaskStepAfterPrepare also normalizes other persisted fields during the transition, this scheduler keeps a stale in-memory task because refreshTaskIfNeeded() only refetches when state/step diverge. The next tick can then plan from outdated prepared data.

Suggested fix
 		if !switched {
 			return nil
 		}
-		task.Step = proto.StepPrepared
-		s.task.Store(task)
+		updatedTask, err := s.taskMgr.GetTaskByID(s.ctx, task.ID)
+		if err != nil {
+			return errors.Trace(err)
+		}
+		s.task.Store(updatedTask)
 		return nil
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/dxf/framework/scheduler/scheduler.go` around lines 398 - 406, After a
successful CAS in SwitchTaskStepAfterPrepare, the code only mutates task.Step
in-memory which can leave other normalized/persisted fields stale; update the
scheduler to reload the authoritative task state and replace the in-memory task
after the switch succeeds. Concretely: in the block that calls
s.taskMgr.SwitchTaskStepAfterPrepare(s.ctx, task), when switched == true,
re-fetch the task from the task manager or call the existing
refreshTaskIfNeeded/refresh logic (or a direct Read/Get method on taskMgr) and
then call s.task.Store(freshTask) instead of only setting task.Step so the
in-memory copy matches any other persisted changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@pkg/dxf/framework/scheduler/scheduler.go`:
- Around line 398-406: After a successful CAS in SwitchTaskStepAfterPrepare, the
code only mutates task.Step in-memory which can leave other normalized/persisted
fields stale; update the scheduler to reload the authoritative task state and
replace the in-memory task after the switch succeeds. Concretely: in the block
that calls s.taskMgr.SwitchTaskStepAfterPrepare(s.ctx, task), when switched ==
true, re-fetch the task from the task manager or call the existing
refreshTaskIfNeeded/refresh logic (or a direct Read/Get method on taskMgr) and
then call s.task.Store(freshTask) instead of only setting task.Step so the
in-memory copy matches any other persisted changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 83ca7229-ed2a-4079-a65c-e2994b5ef455

📥 Commits

Reviewing files that changed from the base of the PR and between 6d34609 and f5a2db8.

📒 Files selected for processing (1)
  • pkg/dxf/framework/scheduler/scheduler.go

@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 22, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
pkg/dxf/framework/scheduler/scheduler_nokit_test.go (1)

543-565: 💤 Low value

Test verifies in-memory task state unchanged when CAS returns false, but the mutated fields from OnPrepare are lost.

When SwitchTaskStepAfterPrepare returns false, the test correctly asserts that scheduler.GetTask() equals taskWithPrepare (the original state before OnPrepare mutations). However, this means the prepared field updates (Meta, RequiredSlots, MaxNodeCount) computed by OnPrepare at lines 548-553 are discarded silently.

This is the expected behavior per the current implementation (another owner won the CAS), but it's worth adding a brief comment in the test clarifying that mutations are intentionally not persisted when switched=false since another scheduler instance already transitioned the task.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/dxf/framework/scheduler/scheduler_nokit_test.go` around lines 543 - 565,
Add a short clarifying comment in the test near the OnPrepare /
SwitchTaskStepAfterPrepare expectation block (around the calls to
schExt.OnPrepare, taskMgr.SwitchTaskStepAfterPrepare, and the assertion of
scheduler.GetTask()) explaining that when SwitchTaskStepAfterPrepare returns
false (CAS lost / another owner advanced the task), any mutations performed by
OnPrepare (Meta, RequiredSlots, MaxNodeCount) are intentionally not persisted to
the in-memory scheduler task; this comment should reference the functions
scheduler.onPending, schExt.OnPrepare, taskMgr.SwitchTaskStepAfterPrepare and
scheduler.GetTask so future readers understand the behavior being asserted.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@pkg/dxf/framework/scheduler/scheduler_nokit_test.go`:
- Around line 543-565: Add a short clarifying comment in the test near the
OnPrepare / SwitchTaskStepAfterPrepare expectation block (around the calls to
schExt.OnPrepare, taskMgr.SwitchTaskStepAfterPrepare, and the assertion of
scheduler.GetTask()) explaining that when SwitchTaskStepAfterPrepare returns
false (CAS lost / another owner advanced the task), any mutations performed by
OnPrepare (Meta, RequiredSlots, MaxNodeCount) are intentionally not persisted to
the in-memory scheduler task; this comment should reference the functions
scheduler.onPending, schExt.OnPrepare, taskMgr.SwitchTaskStepAfterPrepare and
scheduler.GetTask so future readers understand the behavior being asserted.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2584b6b8-c8f1-439b-a4e6-087ac79dff17

📥 Commits

Reviewing files that changed from the base of the PR and between f5a2db8 and a9fe0df.

📒 Files selected for processing (8)
  • pkg/dxf/framework/proto/step.go
  • pkg/dxf/framework/proto/step_test.go
  • pkg/dxf/framework/scheduler/interface.go
  • pkg/dxf/framework/scheduler/scheduler.go
  • pkg/dxf/framework/scheduler/scheduler_nokit_test.go
  • pkg/dxf/framework/storage/task_state_test.go
  • pkg/dxf/framework/storage/task_table.go
  • pkg/server/handler/tikvhandler/dxf.go
✅ Files skipped from review due to trivial changes (1)
  • pkg/server/handler/tikvhandler/dxf.go

@D3Hunter D3Hunter left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

  • Total findings: 5
  • Inline comments: 5
  • Summary-only findings (no inline anchor): 0
Findings (highest risk first)

⚠️ [Major] (2)

  1. Prepare-mode can silently skip business steps for schedulers that do not handle StepPrepared (pkg/dxf/framework/scheduler/scheduler.go:394; pkg/dxf/framework/storage/task_table.go:875; pkg/dxf/importinto/scheduler.go:534; pkg/ddl/backfilling_dist_scheduler.go:238)
  2. target_steps cannot be cleared after switching extra_params updates to JSON merge patch (pkg/dxf/framework/storage/task_table.go:1198; pkg/server/handler/tikvhandler/dxf.go:390; pkg/dxf/framework/proto/task.go:109)

🟡 [Minor] (2)

  1. handlePlanErr name understates scope after prepare-mode integration (pkg/dxf/framework/scheduler/scheduler.go:395; pkg/dxf/framework/scheduler/scheduler.go:628)
  2. Integration test entrypoint mixes runtime-slot behavior with prepare-mode lifecycle coverage (pkg/dxf/framework/integrationtests/framework_test.go:344)

ℹ️ [Info] (1)

  1. Temporary rollout comments lack explicit tracking or removal criteria (pkg/dxf/framework/scheduler/scheduler.go:155; pkg/dxf/framework/scheduler/scheduler.go:409)

Comment thread pkg/dxf/framework/scheduler/scheduler.go
Comment thread pkg/dxf/framework/storage/task_table.go Outdated
Comment thread pkg/dxf/framework/scheduler/scheduler.go
Comment thread pkg/dxf/framework/integrationtests/framework_test.go
Comment thread pkg/dxf/framework/scheduler/scheduler.go
@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented May 22, 2026

Copy link
Copy Markdown

@D3Hunter: PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test.

Details

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label May 25, 2026
@ti-chi-bot

ti-chi-bot Bot commented May 26, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, joechenrh

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added approved lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels May 26, 2026
@ti-chi-bot

ti-chi-bot Bot commented May 26, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-05-25 10:17:25.575608791 +0000 UTC m=+260915.545773846: ☑️ agreed by joechenrh.
  • 2026-05-26 08:09:14.89848907 +0000 UTC m=+339624.868654198: ☑️ agreed by GMHDBJD.

@ti-chi-bot
ti-chi-bot Bot merged commit 0c98567 into pingcap:master May 26, 2026
36 checks passed
@D3Hunter
D3Hunter deleted the import-async-prepare-dxf-part branch May 26, 2026 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants