GO-6331 objectstorestore remove on space leave #2886
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.
PR Description
TL;DR
Problem: When a user was kicked from a space (by another participant), the cleanup only removed ACL indexes via
cleanACLIndexes()but left the space database files on disk. The space data was never fully removed.Solution: Introduce proper space index lifecycle management tied to space mode transitions:
OnSpaceModeChangehook triggersCloseSpaceIndex()when space entersOffloadingmodeDeleteSpaceIndex()permanently deletes the database files from filesystem and marks the proxy as deactivatedWhy storeProxy: The proxy pattern was needed to safely handle the "deactivated but still referenced" state. After a space is deleted, existing code paths (like cross-space subscriptions or late callbacks) might still call
SpaceIndex(deletedSpaceId). Without the proxy:anystore.Open()The proxy solves both: it returns
sharedEmptyStorefor deactivated spaces (safe empty results) and theremovedflag prevents re-initialization even ifInit()is called.Key Concepts
initializedremovedErrSpaceRemovedFlow
Syncstatus optimization
AllLoadedSpaceIds()which only returns spaces inModeLoadingstate