Skip to content

executor: allow canceling import job without dxf task#69659

Open
D3Hunter wants to merge 1 commit into
pingcap:release-nextgen-202603from
D3Hunter:codex/cancel-orphan-import-job-61702
Open

executor: allow canceling import job without dxf task#69659
D3Hunter wants to merge 1 commit into
pingcap:release-nextgen-202603from
D3Hunter:codex/cancel-orphan-import-job-61702

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:

In nextgen user keyspace, IMPORT INTO creates the import job row before submitting the corresponding DXF task in a separate transaction. If the submission fails after the import job is created but before the DXF task is created, CANCEL IMPORT JOB fails with task not found and leaves the import job active.

What changed and how does it work?

When canceling an import job, keep the normal DXF task cancellation path. If waiting by the import task key reports storage.ErrTaskNotFound, treat it as the orphaned pre-DXF-submit case and update the import job state directly with importer.CancelJob.

A regression test creates an import job without a matching DXF task and verifies CANCEL IMPORT JOB marks the job as cancelled.

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.

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

Fix `CANCEL IMPORT JOB` for import jobs whose DXF task was not submitted successfully.

Tests

./tools/check/failpoint-go-test.sh pkg/executor -run TestCancelImportJobWithoutDXFTask -count=1
make bazel_prepare
make lint

Summary by CodeRabbit

  • Bug Fixes

    • Improved import job cancellation so it still completes even if the related distributed task is missing.
    • Added a fallback path that cancels the import job directly and reports a clearer cancellation outcome.
  • Tests

    • Added coverage for cancelling an import job when the related distributed task cannot be found.

@ti-chi-bot ti-chi-bot Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Jul 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@coderabbitai

coderabbitai Bot commented Jul 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ac9a3f42-34e6-4950-8e00-73f506291627

📥 Commits

Reviewing files that changed from the base of the PR and between 0ac299d and cdf93b8.

📒 Files selected for processing (3)
  • pkg/executor/BUILD.bazel
  • pkg/executor/import_into.go
  • pkg/executor/import_into_test.go

📝 Walkthrough

Walkthrough

The executor's import job cancellation logic now handles the case where the DXF distributed task cannot be found by falling back to direct job cancellation via a new helper function. A corresponding test and Bazel dependency were added.

Changes

Import Job Cancellation Fallback

Layer / File(s) Summary
Fallback cancellation logic
pkg/executor/import_into.go
cancelAndWaitImportJob now cancels/waits by task key and, on dxfstorage.ErrTaskNotFound, falls back to a new cancelImportJobOnly helper that cancels the job directly via importer.CancelJob.
Test coverage and build wiring
pkg/executor/import_into_test.go, pkg/executor/BUILD.bazel
Adds TestCancelImportJobWithoutDXFTask asserting cancelled status and error message, with supporting imports and the new Bazel deps entry.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Executor
  participant TaskManager
  participant DXFStorage
  participant Importer

  Executor->>TaskManager: CancelTaskByKeySession(taskKey)
  Executor->>TaskManager: WaitTaskDoneByKey(taskKey)
  TaskManager->>DXFStorage: lookup task
  DXFStorage-->>TaskManager: ErrTaskNotFound
  TaskManager-->>Executor: return error
  Executor->>Executor: cancelImportJobOnly()
  Executor->>Importer: CancelJob()
Loading

Suggested labels: approved, lgtm

Suggested reviewers: joechenrh, GMHDBJD

Poem

A rabbit hops through task and key,
When DXF storage can't be found, you see,
No need to fret, no need to wait —
Cancel it straight, don't hesitate!
🐰 Hop, cancel, done — job's fate is sealed! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: allowing import-job cancellation without a DXF task.
Description check ✅ Passed The description includes the issue reference, problem summary, change details, tests, and release note.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="Running error: context loading failed: failed to load packages: failed to load packages: failed to load with go/packages: context deadline exceeded"
level=error msg="Timeout exceeded: try increasing it by passing --timeout option"


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.

@ti-chi-bot ti-chi-bot Bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Jul 3, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign b41sh for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found 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

@D3Hunter D3Hunter marked this pull request as ready for review July 3, 2026 11:22
@ti-chi-bot ti-chi-bot Bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 3, 2026
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.94737% with 4 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-nextgen-202603@d6e91f7). Learn more about missing BASE report.

Additional details and impacted files
@@                     Coverage Diff                     @@
##             release-nextgen-202603     #69659   +/-   ##
===========================================================
  Coverage                          ?   76.1800%           
===========================================================
  Files                             ?       1935           
  Lines                             ?     540492           
  Branches                          ?          0           
===========================================================
  Hits                              ?     411747           
  Misses                            ?     128745           
  Partials                          ?          0           
Flag Coverage Δ
unit 76.1800% <78.9473%> (?)

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

Components Coverage Δ
dumpling 61.5065% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 48.7782% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant