Skip to content

fix(backup): honor cancellation during object copy - #26289

Merged
XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:agent/backup-cancellation-26246
Jul 28, 2026
Merged

XuPeng-SH merged 2 commits into
matrixorigin:mainfrom
LeftHandCold:agent/backup-cancellation-26246

Conversation

@LeftHandCold

@LeftHandCold LeftHandCold commented Jul 28, 2026 •

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #26246

What this PR does / why we need it:

Current main already contains #26290's bounded admission, first-error sibling
cancellation, joining of scheduled jobs, and missing-object failure semantics.
The remaining bug is that backup object-copy jobs derive their context from
context.Background(), and retry backoff uses the non-context-aware retry
helper. Consequently, canceling BackupData cannot stop a blocked file
operation or interrupt a retry delay.

This PR is intentionally limited to that remaining defect:

  • pass the execBackup caller context into parallelCopyData;
  • derive the existing cancel-cause context from the caller while preserving
    fix(backup): fail on missing checkpoint objects #26290's error and scheduling behavior;
  • use DoWithRetryContext so caller or sibling cancellation interrupts retry
    backoff;
  • add deterministic regressions for cancellation during a blocked read and
    during retry backoff.

Verification:

  • focused cancellation regressions fail to compile on current main because
    parallelCopyData has no caller-context path, and pass after the fix;
  • focused cancellation/concurrency tests: -race -count=100;
  • pkg/backup: full tests and full race tests;
  • pkg/backup: go build and go vet;
  • dependent pkg/datasync.TestCopyFile.

@LeftHandCold
LeftHandCold requested a review from XuPeng-SH as a code owner July 28, 2026 04:37
@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 →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Deep-reviewed exact head fb2c31f against current main 42ba9fb.

The cancellation and ownership model is sound. The caller context now reaches both the scheduled job and every source/destination file operation; context-aware retry makes backoff interruptible. Admission is bounded by parallelism, a permanent error establishes the cancel cause before siblings unwind, and the caller joins every successfully submitted job before reading results or stopping the scheduler. This closes the old undersized errC blocked-send / post-return worker lifetime hazards while preserving the first causal error.

Local verification:

  • caller cancellation, sibling cancellation, and retry-backoff cancellation passed individually under -race for 43/43/44 repetitions;
  • existing backup CopyFileWithRetry and dependent datasync TestCopyFile passed under -race for 43/42 repetitions;
  • the complete pkg/backup package passed under -race;
  • vet, datasync regressions, diff checks, and a prospective merge with latest main passed;
  • all current substantive GitHub CI checks are successful.

Non-blocking coordination: use Fixes #26246 so the issue closes automatically. PR #26290 changes the same scheduler block and test filename; whichever PR lands second must rebase and preserve both contracts: missing checkpoint objects are fatal, and caller cancellation remains end-to-end with joined workers. Also, the timeout cleanup in TestParallelCopyDataCancelsSiblingAfterCopyFailure would be more robust with a second bounded select instead of an unbounded <-result.

@mergify mergify Bot added the queued label Jul 28, 2026
@mergify

mergify Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-28 07:06 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🚫 Left the queue — 2026-07-28 09:00 UTC · at fb2c31f8a89fa501767a18edb788878f67b7fcbf

This pull request spent 1 hour 53 minutes 3 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

merge conflict between base and head

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Requeued — the merge queue status continues in this comment ↓.

@mergify mergify Bot added dequeued and removed queued labels Jul 28, 2026
@mergify

mergify Bot commented Jul 28, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-07-28 11:20 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-07-28 12:30 UTC · at 78755f626185fc939c2f8c328bd96074c2dfe1e2

This pull request spent 1 hour 10 minutes 7 seconds in the queue, with no time running CI.

Reason

The pull request can't be updated

This pull request seems to come from a fork, and Mergify needs the author's permission to update its branch.
The author needs to enable "Allow edits from maintainers" on this pull request, or update the branch manually.

Hint

You should update or rebase your pull request manually. If you do, this pull request will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

@XuPeng-SH
XuPeng-SH merged commit a834096 into matrixorigin:main Jul 28, 2026
22 of 23 checks passed
@mergify mergify Bot added dequeued and removed queued labels Jul 28, 2026
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26246

## What this PR does / why we need it:

Current `main` already contains matrixorigin#26290's bounded admission, first-error
sibling
cancellation, joining of scheduled jobs, and missing-object failure
semantics.
The remaining bug is that backup object-copy jobs derive their context
from
`context.Background()`, and retry backoff uses the non-context-aware
retry
helper. Consequently, canceling `BackupData` cannot stop a blocked file
operation or interrupt a retry delay.

This PR is intentionally limited to that remaining defect:

- pass the `execBackup` caller context into `parallelCopyData`;
- derive the existing cancel-cause context from the caller while
preserving
  matrixorigin#26290's error and scheduling behavior;
- use `DoWithRetryContext` so caller or sibling cancellation interrupts
retry
  backoff;
- add deterministic regressions for cancellation during a blocked read
and
  during retry backoff.

Verification:

- focused cancellation regressions fail to compile on current `main`
because
  `parallelCopyData` has no caller-context path, and pass after the fix;
- focused cancellation/concurrency tests: `-race -count=100`;
- `pkg/backup`: full tests and full race tests;
- `pkg/backup`: `go build` and `go vet`;
- dependent `pkg/datasync.TestCopyFile`.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26246

## What this PR does / why we need it:

Current `main` already contains matrixorigin#26290's bounded admission, first-error
sibling
cancellation, joining of scheduled jobs, and missing-object failure
semantics.
The remaining bug is that backup object-copy jobs derive their context
from
`context.Background()`, and retry backoff uses the non-context-aware
retry
helper. Consequently, canceling `BackupData` cannot stop a blocked file
operation or interrupt a retry delay.

This PR is intentionally limited to that remaining defect:

- pass the `execBackup` caller context into `parallelCopyData`;
- derive the existing cancel-cause context from the caller while
preserving
  matrixorigin#26290's error and scheduling behavior;
- use `DoWithRetryContext` so caller or sibling cancellation interrupts
retry
  backoff;
- add deterministic regressions for cancellation during a blocked read
and
  during retry backoff.

Verification:

- focused cancellation regressions fail to compile on current `main`
because
  `parallelCopyData` has no caller-context path, and pass after the fix;
- focused cancellation/concurrency tests: `-race -count=100`;
- `pkg/backup`: full tests and full race tests;
- `pkg/backup`: `go build` and `go vet`;
- dependent `pkg/datasync.TestCopyFile`.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
VioletQwQ-0 pushed a commit to VioletQwQ-0/matrixone that referenced this pull request Sep 17, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [ ] Improvement
- [ ] Documentation
- [ ] Feature
- [ ] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

issue matrixorigin#26246

## What this PR does / why we need it:

Current `main` already contains matrixorigin#26290's bounded admission, first-error
sibling
cancellation, joining of scheduled jobs, and missing-object failure
semantics.
The remaining bug is that backup object-copy jobs derive their context
from
`context.Background()`, and retry backoff uses the non-context-aware
retry
helper. Consequently, canceling `BackupData` cannot stop a blocked file
operation or interrupt a retry delay.

This PR is intentionally limited to that remaining defect:

- pass the `execBackup` caller context into `parallelCopyData`;
- derive the existing cancel-cause context from the caller while
preserving
  matrixorigin#26290's error and scheduling behavior;
- use `DoWithRetryContext` so caller or sibling cancellation interrupts
retry
  backoff;
- add deterministic regressions for cancellation during a blocked read
and
  during retry backoff.

Verification:

- focused cancellation regressions fail to compile on current `main`
because
  `parallelCopyData` has no caller-context path, and pass after the fix;
- focused cancellation/concurrency tests: `-race -count=100`;
- `pkg/backup`: full tests and full race tests;
- `pkg/backup`: `go build` and `go vet`;
- dependent `pkg/datasync.TestCopyFile`.

Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>

This branch was previously deployed

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

Labels

kind/bug Something isn't working size/M Denotes a PR that changes [100,499] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants