Skip to content

fix(upload): use reliable staging preallocation - #626

Merged
AptS-1547 merged 1 commit into
masterfrom
fix/staging-preallocation-623
Sep 18, 2026
Merged

AptS-1547 merged 1 commit into
masterfrom
fix/staging-preallocation-623

Conversation

@AptS-1547

@AptS-1547 AptS-1547 commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

Pull request

Summary

  • replace the unmaintained fs2 production dependency with revision-pinned aster-fs
  • use the corrected Apple allocation contract for upload staging, local capacity probes, and chunk-file locks while keeping filesystem work inside Tokio's blocking pool
  • preserve staged-upload capacity admission, stable HTTP 507 mapping, cleanup, restart recovery, and existing chunk data
  • document the Apple allocation contract and add an APFS-sized integration regression

The underlying defect was fixed and reviewed in AsterCommunity/AsterFs#2. On Apple filesystems, new reservations now use F_ALLOCATEALL, validate fstore_t.fst_bytesalloc before extending logical EOF, and recover actual sparse holes without changing existing data or cursor position.

Closes #623.

Test plan

  • Not needed: documentation, metadata, or configuration-only change
  • Backend: cargo check --locked --tests
  • Backend: targeted cargo nextest run --locked --profile ci --lib services::files::upload::ingest::staging::tests
  • Backend: targeted cargo nextest run --locked --profile ci --test files staging
  • Backend: targeted cargo nextest run --locked --profile ci --test files staged
  • Backend: targeted cargo nextest run --locked --profile ci --test files macos_chunked_init_reserves_large_apfs_staging_file
  • Backend: cargo clippy --locked --tests -- -D warnings
  • Frontend: bun run check
  • Frontend: bun run build
  • Manual UI check for user-facing changes
  • Developer docs: OpenAPI validation and 433-page build with internal-link verification
  • Formatting and whitespace: cargo fmt --all -- --check, git diff --check, git diff --cached --check, and git diff HEAD --check

Cross-platform allocation evidence for aster-fs includes its Rust 1.75 sync-feature MSRV check, feature build/test/clippy matrix, Apple limited-volume APFS tests, native Linux Docker/tmpfs ENOSPC probes, native Windows NTFS/VHDX ENOSPC probes, and affected Linux/macOS/Windows cross-target checks.

Notes for reviewers

  • Database migrations: none
  • Runtime configuration changes: none
  • Deployment or upgrade notes: the new Git dependency is pinned to merged AsterFs commit 913ed30598119c184f49f18e5b339fc98869fff2
  • Scope: upload staging only; archive-download behavior is intentionally excluded

Summary by CodeRabbit

  • Bug 修复

    • 改进 Apple 文件系统上的上传暂存空间预留,确保分配失败时不会留下不完整的会话预留。
    • 恢复稀疏上传会话时,仅补足实际缺失的空间,不修改已有数据,也不会误报恢复成功。
    • 暂存空间不足时继续返回稳定的 HTTP 507 错误,并自动清理相关临时内容。
  • 文档

    • 更新上传容量检查与暂存恢复行为说明,补充 Apple 文件系统上的处理规则。

@coderabbitai

coderabbitai Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 31f22c5a-935f-42bc-a1ec-923cd2339cc1

📥 Commits

Reviewing files that changed from the base of the PR and between 9edbd7e and 0244d3d.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • CHANGELOG.md
  • CHANGELOG.zh.md
  • Cargo.toml
  • developer-docs/en/design/upload-finalization-contracts.md
  • developer-docs/zh-CN/design/upload-finalization-contracts.md
  • src/services/files/upload/ingest/chunk.rs
  • src/services/files/upload/ingest/staging.rs
  • src/storage/drivers/local/driver_impl.rs
  • tests/files/upload.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

本次变更将上传暂存和本地容量操作迁移到固定 revision 的 aster-fs。APFS 预留测试验证物理分配、稀疏会话恢复和容量不足处理。相关设计文档与变更日志已更新。

Changes

上传暂存预留契约

Layer / File(s) Summary
aster-fs 契约接入
Cargo.toml, src/services/files/upload/ingest/staging.rs, src/services/files/upload/ingest/chunk.rs, src/storage/drivers/local/driver_impl.rs
移除 fs2,改用固定 revision 的 aster-fs。上传暂存使用新的容量、物理分配和文件锁 API。本地容量查询保持原有返回结构和错误映射。
预留行为验证与文档同步
tests/files/upload.rs, developer-docs/.../upload-finalization-contracts.md, CHANGELOG*.md
新增 macOS APFS 大文件预留测试,并更新稀疏会话恢复、容量不足及并发预留测试。中英文设计文档和变更日志记录新的 APFS 分配契约。

Priority: ➖ Normal

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

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: apts-1738

Merge Risk: ⚪ Minimal · up to 0244d

The filesystem migration preserves the inspected reservation, locking, and capacity-reporting behaviors, with no actionable merge-blocking risk identified.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 70.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 4 files. (5 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check ❓ Inconclusive #623 的主要编码目标有对应变更:fs2 已替换为 revision-pinned aster-fs;staging、chunk lock 和本地容量探测已迁移;Tokio blocking 语义、507 映射、清理、恢复和完成行为由摘要声明保持;新增 macOS APFS 回归测试及契约文档。摘要未提供足够证据确认所有当前目标平台都实现了显式不支持错误,也未证明 Linux Docke… 需要可审查的证据确认 Linux、macOS、Windows 的 reservation 实现及 unsupported primitive 的显式失败路径,并确认 Linux Docker 验证、Windows VM 验证和受影响 release target 的交叉编译结果。
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed 标题准确概括了主要变更:修复上传暂存空间的可靠预分配。措辞简洁且与代码、测试和文档变更一致。
Description check ✅ Passed 描述完整覆盖变更摘要、测试计划、审查说明、依赖固定版本、配置影响和部署说明。测试命令、回归测试及范围限制均已列出。
Out of Scope Changes check ✅ Passed 摘要中的依赖替换、staging 与文件锁迁移、容量探测迁移、APFS 回归测试、契约文档和中英文 changelog 都直接支持 #623 的平台预留修复、恢复语义或验证要求。未见与该问题无关的功能变更。
Full details: Linked Issues check

Explanation

#623 的主要编码目标有对应变更:fs2 已替换为 revision-pinned aster-fs;staging、chunk lock 和本地容量探测已迁移;Tokio blocking 语义、507 映射、清理、恢复和完成行为由摘要声明保持;新增 macOS APFS 回归测试及契约文档。摘要未提供足够证据确认所有当前目标平台都实现了显式不支持错误,也未证明 Linux Docker 验证、Windows VM 验证和全部受影响 release target 的交叉编译已完成。Cargo.lock 被明确排除,不能据此判断依赖锁文件状态。

Full details: Docstring Coverage

Explanation

Docstring coverage is 70.59% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 4 files. (5 skipped: 5 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

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

APFS 的洞不再冒充答案
预留按契约稳稳落盘
稀疏会话补回真实空间
507 守住容量边界
fs2 退场,aster-fs 接班
猫猫,这次别让块再撒谎

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

@astercommunity-automation astercommunity-automation Bot added Documentation Improvements or additions to documentation Dependencies Pull requests that update a dependency file Priority: High High priority issue Rust Pull requests that update Rust code Scope: Storage Storage policies, connectors, drivers, provider capabilities, and storage backends Scope: Files Core file and folder product behavior Scope: Upload Upload negotiation, sessions, staging, completion, and ingress consistency Risk: High Changes a high-risk data, security, protocol, or deployment boundary CI: Running A pull request has required CI workflows that have not reached a terminal state labels Sep 18, 2026
@astercommunity-automation

astercommunity-automation Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

PR readiness for 0244d3ddc7c8

Fact Value
Blocking conditions 1
Waiting conditions 0
Current unresolved threads 0
Current-head approvals 0
Stale latest reviews 0
  • BLOCK: Current head requires a human approval

This report is deterministic and updated for the current pull request head.

@astercommunity-automation

astercommunity-automation Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

CI diagnostics resolved for 0244d3ddc7c8

Workflow Result First failing job/step
Rust CI PASS -
E2E PASS -
Security Audit PASS -
Docs Check PASS -
Multi-Primary E2E PASS -
WebDAV Compatibility PASS -

This comment is updated in place for the latest PR head.

@codecov

codecov Bot commented Sep 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.90909% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/services/files/upload/ingest/staging.rs 85.71% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@astercommunity-automation astercommunity-automation Bot added CI: Passed All required CI workflows passed for the current pull request head and removed CI: Running A pull request has required CI workflows that have not reached a terminal state labels Sep 18, 2026
@AptS-1547
AptS-1547 merged commit 9ab6e47 into master Sep 18, 2026
23 of 27 checks passed
@astercommunity-automation astercommunity-automation Bot added Merged Pull request has been merged and removed CI: Passed All required CI workflows passed for the current pull request head labels Sep 18, 2026
@AptS-1547
AptS-1547 deleted the fix/staging-preallocation-623 branch October 16, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Dependencies Pull requests that update a dependency file Documentation Improvements or additions to documentation Merged Pull request has been merged Priority: High High priority issue Risk: High Changes a high-risk data, security, protocol, or deployment boundary Rust Pull requests that update Rust code Scope: Files Core file and folder product behavior Scope: Storage Storage policies, connectors, drivers, provider capabilities, and storage backends Scope: Upload Upload negotiation, sessions, staging, completion, and ingress consistency

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: APFS staging preallocation is rejected after successful upload reservation

1 participant