Skip to content

fix(storage): 等待 AGFS 复制收尾后再传播取消 - #6178

Merged
qin-ctx merged 1 commit into
volcengine:mainfrom
qin-ptr:fix/agfs-io-cancellation
Oct 19, 2026
Merged

qin-ctx merged 1 commit into
volcengine:mainfrom
qin-ptr:fix/agfs-io-cancellation

Conversation

@qin-ptr

@qin-ptr qin-ptr commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Description

补齐 AGFS cp 的取消收尾保护。普通 AGFS 调用已经等待底层 I/O 完成,但复制仍直接等待 asyncio.to_thread,取消后可能提前释放外层锁或开始清理。

以持有目标路径锁,将 /local/account/source 复制到 /local/account/file 时取消任务为例:

  • 修改前: 协程立即抛出 CancelledError,调用方开始释放锁或清理,底层复制线程仍可能继续写入。
  • 修改后: 等当前复制结束后再抛出 CancelledError,外层锁和清理流程不会先于复制收尾;连续取消也保持这个顺序。

Human Involvement

  • A human participated in the implementation or review loop
  • This PR was generated entirely by AI agents without human participation in the loop

Related Issue

无关联 Issue。

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

  • cp 复用现有 run_to_completion,统一复制线程与协程的收尾顺序。
  • 简化普通调用的绑定方法查找和局部参数处理,保留已有取消保护及 ctx 兼容行为。
  • 扩展现有取消契约测试,覆盖复制和连续取消,保留 AGFS、向量写入覆盖;没有新增测试文件。

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

改写现有测试补充回归覆盖。以下聚焦测试全部通过(27 passed):

python -m pytest tests/agfs/test_async_client.py tests/pyagfs/test_async_client_fs_ctx.py tests/test_task_tracker_concurrency.py -o addopts='' -q

回放修复前的 cp 实现时,复制取消用例失败,原有 AGFS 与向量用例通过。Ruff 检查、格式检查及 git diff --check 通过。

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

不适用。

Additional Notes

取消不会回滚已经开始的复制;取消响应需要等待当前复制收尾。无新增依赖或 API 参数。

相对 main,生产代码净减 4 行,测试净增 5 行,合计净增 1 行。

Keep caller cleanup behind the physical copy lifetime, including repeated cancellation.

Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com>
@qin-ctx
qin-ctx merged commit dfc22d1 into volcengine:main Oct 19, 2026
8 of 9 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Oct 19, 2026
qin-ctx added a commit that referenced this pull request Oct 19, 2026
Keep caller cleanup behind the physical copy lifetime, including repeated cancellation.

Co-authored-by: qin-ptr <222410531+qin-ptr@users.noreply.github.com>
Co-authored-by: qin-ctx <qinhaojie.exe@bytedance.com>
(cherry picked from commit dfc22d1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants