You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(server): cleanup embedding after workspace deleted - #15851
Workspace deletion now more reliably removes associated documents, search data, embeddings, and other workspace records, including when cleanup is retried or object deletion encounters errors.
Cleanup waits for in-progress embedding updates and prevents deleted workspace data from reappearing. Reconciliation also removes orphaned search documents and blocks while preserving data for live workspaces.
Banning an account now removes its workspace, access policies, and associated data.
No actionable comments were generated in the recent review.
Walkthrough
Workspace cleanup now discovers and removes orphan rows across additional runtime tables, with embedding-table availability passed through deletion and reconciliation. Native and server tests cover cleanup during workspace deletion, including remote search projections and account bans.
Changes: Workspace-scoped storage cleanup
Layer / File(s)
Summary
Discover and delete orphan storage rows packages/backend/native/src/runtime/storage_runtime/workspace_cleanup_checkpoint.rs, packages/backend/native/src/runtime/storage_runtime/workspace_cleanup.rs, packages/backend/native/src/runtime/storage_runtime/mod.rs
Orphan-row discovery and deletion now cover expanded workspace-storage tables and configured checkpoint kinds. Cleanup paths pass embedding-table availability through targeted deletion and reconciliation. The runtime module updates related exports and imports.
Validate native cleanup and embedding commit fencing packages/backend/native/src/runtime/storage_runtime/workspace_cleanup.rs, packages/backend/native/src/runtime/backend_runtime/embedding/store.rs
Database-backed tests cover live-workspace preservation, orphan cleanup, repeat deletion, and reconciliation. The embedding test coordinates a commit with workspace deletion and checks that later commits cannot restore deleted rows.
Validate server workspace deletion cleanup packages/backend/server/src/__tests__/e2e/indexer/remote-provider.spec.ts, packages/backend/server/src/__tests__/e2e/user/account.spec.ts, packages/backend/server/e2e/remote-provider/README.md
The remote-provider test checks that deletion and reconciliation remove workspace rows from OpenSearch. The account-ban test checks removal of workspace-scoped records. The README updates setup instructions and suite coverage.
Entitlement test precision
Layer / File(s)
Summary
Set expiration at millisecond precision packages/backend/native/src/runtime/backend_runtime/entitlement/tests.rs
The entitlement test truncates the statement timestamp to milliseconds when setting the subscription expiration time.
toeverything/AFFiNE#15822: This PR changes delete_orphan_storage_rows and workspace-deletion cleanup behavior in the same checkpoint module.
Merge Risk: Moderate · up to 65418
The new workspace-deletion cleanup could delete the global root-inspection cursor, which may stop inspection from reaching workspaces beyond the first batch. Several earlier concerns about root-source error reporting and sync state also remain open. Resolve or explicitly accept these before merging.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "feat(server): cleanup embedding after workspace deleted" matches the main change. The raw summary shows that workspace deletion now also removes embedding-table rows (checked by embedding_t…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat(server): cleanup embedding after workspace deleted" matches the main change. The raw summary shows that workspace deletion now also removes embedding-table rows (checked by embedding_tables_exist and passed into orphan-row cleanup), and the tests verify that all workspace rows, including embedding rows, are removed after deletion. The title is specific and describes the primary behavior. The title does not mention the test, reconciliation, or lock-ordering changes, but those are supporting details and not the main point.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by CodeRabbit