Skip to content

meta: reap detached trees that contain immutable files - #7407

Open
solracsf wants to merge 1 commit into
juicedata:mainfrom
solracsf:fix/detached-tree-immutable
Open

meta: reap detached trees that contain immutable files#7407
solracsf wants to merge 1 commit into
juicedata:mainfrom
solracsf:fix/detached-tree-immutable

Conversation

@solracsf

Copy link
Copy Markdown
Contributor

Clone copies the source node wholesale, flags included, so cloning a tree with a chattr +i file produces immutable copies. When a clone is interrupted the top directory stays detached, and its cleanup goes through emptyDir -> BatchUnlink/Rmdir, which refuse entries carrying FlagImmutable or FlagAppend (uid 0 does not bypass that). CleanupDetachedNodesBefore then failed on the tree on every gc --delete, logging an error each run while the tree kept its slice references alive, so those blocks could never be reclaimed.

Mark the context used to remove a detached tree and let the flag checks in doBatchUnlink and doRmdir stand down for it, in all three engines. A detached tree is unreachable and this cleanup is its only way out.

Removal of reachable files is untouched: the marker is set only by doCleanupDetachedNode.

Clone copies the source node wholesale, flags included, so cloning a tree
with a chattr +i file produces immutable copies. When a clone is
interrupted the top directory stays detached, and its cleanup goes through
emptyDir -> BatchUnlink/Rmdir, which refuse entries carrying FlagImmutable
or FlagAppend (uid 0 does not bypass that). CleanupDetachedNodesBefore then
failed on the tree on every gc --delete, logging an error each run while the
tree kept its slice references alive, so those blocks could never be
reclaimed.

Mark the context used to remove a detached tree and let the flag checks in
doBatchUnlink and doRmdir stand down for it, in all three engines. A
detached tree is unreachable and this cleanup is its only way out. Removal
of reachable files is untouched: the marker is set only by
doCleanupDetachedNode.

Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf
solracsf force-pushed the fix/detached-tree-immutable branch from 60f5d46 to 86f46e0 Compare August 17, 2026 12:02
@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 60.00000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 45.03%. Comparing base (53835e2) to head (86f46e0).

Files with missing lines Patch % Lines
pkg/meta/sql.go 40.00% 0 Missing and 3 partials ⚠️
pkg/meta/tkv.go 40.00% 0 Missing and 3 partials ⚠️
pkg/meta/redis.go 60.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #7407       +/-   ##
===========================================
+ Coverage   34.47%   45.03%   +10.56%     
===========================================
  Files         140      177       +37     
  Lines       48322    58723    +10401     
===========================================
+ Hits        16658    26448     +9790     
+ Misses      29984    29212      -772     
- Partials     1680     3063     +1383     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant