Skip to content

revert: remove MFS auto-flush mechanism#1041

Merged
lidel merged 1 commit intomainfrom
fix/revert-mfs-cache-limit
Sep 25, 2025
Merged

revert: remove MFS auto-flush mechanism#1041
lidel merged 1 commit intomainfrom
fix/revert-mfs-cache-limit

Conversation

@lidel
Copy link
Member

@lidel lidel commented Sep 22, 2025

This PR removes the cache auto-flush feature from #1037 that could cause data corruption with parallel MFS operations.

letting applications implement their own safety mechanisms is safer than enforcing automatic flushing in the library.

cc ipfs/kubo#10842

removes the cache auto-flush feature from #1037 that could cause
data corruption with parallel MFS operations.

letting applications implement their own safety mechanisms is safer
than enforcing automatic flushing in the library.

related to ipfs/kubo#10842
@lidel lidel requested a review from hsanjuan September 22, 2025 20:53
@lidel lidel mentioned this pull request Sep 20, 2025
49 tasks
@codecov
Copy link

codecov bot commented Sep 22, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.71%. Comparing base (031df82) to head (6f0b6f7).
⚠️ Report is 2 commits behind head on main.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1041      +/-   ##
==========================================
+ Coverage   60.58%   60.71%   +0.13%     
==========================================
  Files         263      268       +5     
  Lines       33502    33569      +67     
==========================================
+ Hits        20296    20381      +85     
+ Misses      11531    11515      -16     
+ Partials     1675     1673       -2     
Files with missing lines Coverage Δ
mfs/dir.go 51.70% <ø> (+0.15%) ⬆️
mfs/root.go 30.68% <ø> (+0.68%) ⬆️

... and 20 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

lidel added a commit to ipfs/kubo that referenced this pull request Sep 23, 2025
adds a global counter that tracks consecutive MFS operations performed
with --flush=false and fails with clear error after limit is reached.

this prevents unbounded memory growth while avoiding the data corruption
risks of auto-flushing.

- adds Internal.MFSNoFlushLimit config
- operations fail with actionable error at limit
- counter resets on successful flush or any --flush=true operation
- operations with --flush=true reset and don't count

this commit removes automatic flush from #10971
and instead errors to encourage users of --flush=false to develop a habit
of calling 'ipfs files flush' periodically.

boxo will no longer auto-flush (ipfs/boxo#1041) to
avoid corruption issues, and kubo applies the limit to 'ipfs files' commands
instead.

closes #10842
@lidel lidel marked this pull request as ready for review September 23, 2025 00:26
@lidel lidel requested a review from a team as a code owner September 23, 2025 00:26
@lidel lidel merged commit 260f4b3 into main Sep 25, 2025
18 checks passed
@lidel lidel deleted the fix/revert-mfs-cache-limit branch September 25, 2025 22:43
lidel added a commit to ipfs/kubo that referenced this pull request Sep 25, 2025
* fix: add MFS operation limit for --flush=false

adds a global counter that tracks consecutive MFS operations performed
with --flush=false and fails with clear error after limit is reached.

this prevents unbounded memory growth while avoiding the data corruption
risks of auto-flushing.

- adds Internal.MFSNoFlushLimit config
- operations fail with actionable error at limit
- counter resets on successful flush or any --flush=true operation
- operations with --flush=true reset and don't count

this commit removes automatic flush from #10971
and instead errors to encourage users of --flush=false to develop a habit
of calling 'ipfs files flush' periodically.

boxo will no longer auto-flush (ipfs/boxo#1041) to
avoid corruption issues, and kubo applies the limit to 'ipfs files' commands
instead.

closes #10842

* test: add tests for MFSNoFlushLimit

tests verify the new Internal.MFSNoFlushLimit config option:
- default limit of 256 operations
- custom limit configuration
- counter reset on flush=true
- counter reset on explicit flush command
- limit=0 disables the feature
- multiple MFS command types count towards limit

* docs: explain why MFS operations fail instead of auto-flushing

addresses feedback from #10985 (review)

- clarify that automatic flushing at limit was considered but rejected
- explain the data corruption risks of auto-flushing
- guide users who want auto-flush to use --flush=true (default)
- document benefits of explicit failure for batch operations
lidel added a commit to ipfs/kubo that referenced this pull request Sep 27, 2025
* fix: add MFS operation limit for --flush=false

adds a global counter that tracks consecutive MFS operations performed
with --flush=false and fails with clear error after limit is reached.

this prevents unbounded memory growth while avoiding the data corruption
risks of auto-flushing.

- adds Internal.MFSNoFlushLimit config
- operations fail with actionable error at limit
- counter resets on successful flush or any --flush=true operation
- operations with --flush=true reset and don't count

this commit removes automatic flush from #10971
and instead errors to encourage users of --flush=false to develop a habit
of calling 'ipfs files flush' periodically.

boxo will no longer auto-flush (ipfs/boxo#1041) to
avoid corruption issues, and kubo applies the limit to 'ipfs files' commands
instead.

closes #10842

* test: add tests for MFSNoFlushLimit

tests verify the new Internal.MFSNoFlushLimit config option:
- default limit of 256 operations
- custom limit configuration
- counter reset on flush=true
- counter reset on explicit flush command
- limit=0 disables the feature
- multiple MFS command types count towards limit

* docs: explain why MFS operations fail instead of auto-flushing

addresses feedback from #10985 (review)

- clarify that automatic flushing at limit was considered but rejected
- explain the data corruption risks of auto-flushing
- guide users who want auto-flush to use --flush=true (default)
- document benefits of explicit failure for batch operations

(cherry picked from commit a688b7e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants