Skip to content

fix(decomposedfs): invalidate all space indexes on purge - #695

Merged
aduffeck merged 1 commit into
opencloud-eu:mainfrom
michaelstingl:issue-2985-purge-index
Jun 26, 2026
Merged

aduffeck merged 1 commit into
opencloud-eu:mainfrom
michaelstingl:issue-2985-purge-index

Conversation

@michaelstingl

Copy link
Copy Markdown

Description

The purge branch of DeleteStorageSpace removed only the by-type index. It left the purged space referenced in the by-user-id and by-group indexes, for the space owner and for every grantee. After a purge the on-disk space tree is gone, but those index entries remain. The search service then walks each indexed space and logs an error for the missing one on every pass.

Root cause: updateIndexes populates the by-type index and the by-user-id / by-group indexes (the owner on space creation, each grantee on share), but the purge only called spaceTypeIndex.Remove. A // TODO invalidate ALL indexes in msgpack, not only by type at that call site noted the gap.

Fix: on purge, also remove the space from the by-user-id and by-group indexes, for the owner (read from the OwnerIDAttr extended attribute) and for each grantee (from ListGrants). Removal is best effort: the purge logs an index error and continues, the same way the expired-grant removal already does.

The same gap exists in both decomposedfs trees, so the fix covers both: pkg/storage/pkg/decomposedfs (used by the decomposeds3, decomposed and posix drivers) and pkg/storage/utils/decomposedfs (used by the ocis and s3ng drivers).

Scope: this stops new stale index entries on purge. It does not delete the S3 objects that a purge already leaves behind on the decomposedS3 driver (a separate blob-removal concern), and it does not clean up spaces that were orphaned before this change.

Related Issue

Motivation and Context

Any space purge leaves a stale reference in the by-user-id / by-group index. The issue surfaced after a delete-and-recreate of a project space, where the old space stays referenced for the owner and the shared users. The reproduction and the root-cause trace are in the linked issue.

How Has This Been Tested?

  • go test and go vet on both decomposedfs packages (full suites pass)
  • golangci-lint v2.10.1 (pinned in the Makefile) on both packages: 0 issues
  • new specs (both trees): purge removes the owner, user-grantee and group-grantee index entries, and keeps a sibling space's entry
  • end to end on a patched build (decomposedS3 + MinIO): after sharing a space with a user and a group and purging it, the space id dropped from 4 index files to 0
  • not covered: a behat acceptance scenario

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Technical debt
  • Tests only (no source changes)

Checklist:

  • Code changes
  • Unit tests added
  • Acceptance tests added (the behat suite has no space-purge index scenario; this PR covers it at the unit level, and a behat scenario can follow in the opencloud repo)
  • Documentation added (n/a; reva builds the changelog from the PR title and Type:* label via ready-release-go, so no fragment is needed)

🤖 drafted with Claude Code, reviewed before submitting.

@aduffeck aduffeck left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening the PR. Can you please revert the changes in utils/decomposedfs? It's supposed to be a verbatim copy of the ocis storage driver implementation shouldn't be changed.

The rest of the changes looks good to me 👍

Purging a space removed only the by-type index, leaving stale entries in
the by-user-id and by-group indexes for the owner and every grantee. The
search service then logs an error for every orphaned space on each
indexing pass, and the space id remains in the on-disk index files.

Remove the space from the by-user-id and by-group indexes for the owner
and each grantee on purge, the same way an expired grant is already
removed. This covers both decomposedfs trees (pkg, used by the
decomposeds3, decomposed and posix drivers, and utils, used by the ocis
and s3ng drivers).

Fixes: opencloud-eu/opencloud#2985
@michaelstingl
michaelstingl force-pushed the issue-2985-purge-index branch from 55c9213 to 781d330 Compare June 25, 2026 15:13
@michaelstingl

Copy link
Copy Markdown
Author

Done — reverted both pkg/storage/utils/decomposedfs/ files (spaces.go + spaces_test.go) so the mirror stays a verbatim copy of the ocis driver. The fix and its test now live only in pkg/storage/pkg/decomposedfs/.

Could you approve the pipeline run when you get a chance? As a non-member my pushes need approval before CI can run. Thanks!

🤖 drafted with Claude Code, reviewed before submitting.

@aduffeck
aduffeck merged commit 71216b2 into opencloud-eu:main Jun 26, 2026
19 checks passed
@aduffeck

Copy link
Copy Markdown
Member

Merged, thanks!

michaelstingl added a commit to michaelstingl/opencloud-eu-reva that referenced this pull request Jun 27, 2026
The space index tests added in opencloud-eu#695 purge a project space as its owner
(a space manager) and expect success. opencloud-eu#672 later restricted managers to
disabling spaces, so that only a delete-all-spaces user may purge. The opencloud-eu#695
branch predated that change and was not rebased onto it, so a textually clean
merge left these three tests failing on main.

Purge as a delete-all-spaces user instead, matching the current permission
model. Disabling stays with the space manager. Test-only, no production change.
michaelstingl added a commit to michaelstingl/opencloud-eu-reva that referenced this pull request Jun 27, 2026
… restriction

The space index tests added in opencloud-eu#695 purge a project space as its owner (a
space manager) and expect success. opencloud-eu#672 later restricted managers to disabling
spaces, so that only a delete-all-spaces user may purge. The opencloud-eu#695 branch
predated that change and was not rebased onto it, so a textually clean merge
left these three tests failing on main.

Purge as a delete-all-spaces user in those tests, matching the current
permission model, and add the missing counterpart assertion: a space manager
may disable a project space but not purge it. Test-only, no production change.
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.

Orphaned S3 blobs and stale user index entries after space deletion and recreation — no cleanup path available

2 participants