You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug] Backup ignores caller cancellation while copying object files #26246
Object-file copying during a backup no longer observes the context passed to BackupData. Once copying has started, cancellation or a deadline on the caller does not make the backup return until the active file operation itself finishes.
Reproduction
Start a backup that reaches parallelCopyData with a file service whose Read(ctx, ...) waits for its context to finish.
Cancel the context originally passed to the backup after Read has started.
The copy remains waiting; it returns only after the test manually releases the file service.
The behavior reproduced 3/3 times on 8c9bb66898afa74f8b231e1915d99489ae8a0da7.
Actual behavior
execBackup receives the caller context, but parallelCopyData initializes each job with context.Background() and invokes CopyFileWithRetry(context.Background(), ...). The worker wait is unbounded, so a blocked copy keeps the backup request active after the caller has cancelled it.
Expected behavior
The copy jobs and retry loop should derive from the backup caller context. A cancelled or expired backup request should return promptly and stop waiting for outstanding copy work.
Impact
A backup operation can remain active longer than its caller allows when a storage read or write does not finish.
Activity
LeftHandCold commentedon Jul 28, 2026
已在当前
main(6004becb56adc7f4d22dbfb9554bef8d7091e25d)确认是生产可达的真实问题。根因是
BackupData虽然收到 caller context,但parallelCopyData创建 job 和调用CopyFileWithRetry时都换成了context.Background();同时旧的 retry helper 也不能在 backoff 中响应取消。另一个并发边界是单槽errC会让多个失败 worker 阻塞,函数提前 return/close 后存在生命周期风险。修复 PR:#26289
修复会贯穿 caller context、用 cancel cause 保留首个根因并取消兄弟任务、有界接单且等待所有已提交任务退出,同时改用 context-aware retry。新增 blocked read、retry backoff、兄弟任务取消的确定性回归;
pkg/backup完整 non-race/race、focused-race -count=100、build/vet 和pkg/datasync.TestCopyFile均通过。fix(backup): honor cancellation during object copy (#26289)
LeftHandCold commentedon Jul 31, 2026
fixed
Ariznawlll commentedon Aug 3, 2026
测试版本
main6b3ad84c9d01d453c2bcdd0f440637350e3aa8c6pkg/backup对复制 read 与 retry backoff 做确定性阻塞/取消注入,并运行正常复制控制。原问题验证
原问题是调用方取消备份后,复制任务错误使用独立背景 context,仍继续复制或在 retry backoff 中等待。本轮定向测试连续执行 3 轮:在 read 已经开始后取消 caller context,任务均及时以
context canceled返回;在 retry backoff 中取消也立即停止,而非等待下一次重试。Happy Path 覆盖
TestCopyFileWithRetry和成功 provider-copy 控制路径连续 3 轮通过。TestBackupData连续 3 轮完成备份、重启、恢复和扫描校验,未影响正常备份链路。Unhappy Path 覆盖
context canceled。白盒验证
取消时序和 retry backoff 需要可控阻塞点,采用
TestParallelCopyDataHonorsCallerCancellation、TestCopyFileWithRetryStopsDuringBackoff等确定性包内测试;定向go test -race ./pkg/backup -run '^TestParallelCopyDataHonorsCallerCancellation$'通过(ok .../pkg/backup 1.897s)。相关回归位于pkg/backup/tae_parallel_copy_test.go。回归测试
该问题需要控制 FileService 阻塞与取消时序,回归保持在
pkg/backup白盒测试;不适合作为普通 motr SQL 黑盒 case。测试证据
取消、backoff、sibling 生命周期和正常复制定向用例
-count=3全部通过:ok github.com/matrixorigin/matrixone/pkg/backup 0.905s;完整备份恢复控制-count=3通过:ok github.com/matrixorigin/matrixone/pkg/backup 5.286s。测试结论
测试通过。
fix(backup): honor cancellation during object copy (matrixorigin#26289)
fix(backup): honor cancellation during object copy (matrixorigin#26289)
fix(backup): honor cancellation during object copy (matrixorigin#26289)