Skip to content

Explicitly close the index when shutting down SourceKit-LSP#2483

Merged
ahoppen merged 1 commit into
swiftlang:mainfrom
ahoppen:explicitly-close-index
Mar 1, 2026
Merged

Explicitly close the index when shutting down SourceKit-LSP#2483
ahoppen merged 1 commit into
swiftlang:mainfrom
ahoppen:explicitly-close-index

Conversation

@ahoppen

@ahoppen ahoppen commented Feb 15, 2026

Copy link
Copy Markdown
Member

IndexStoreDB moves its index to the saved directory when it is deallocated. Because IndexStoreDB is primarily owned by UncheckedIndex, we rely on deallocating this object to save the index store. This is fairly brittle because various parts of the codebase may hold transient references to that object as reported in #2455 (comment).

Explicitly remove the reference from UncheckedIndex to IndexStoreDB. While this still isn’t perfect because other parts of the code base may hold references to IndexStoreDB but those should be a lot rarer, resulting in a more consistent closing of the index.

`IndexStoreDB` moves its index to the `saved` directory when it is deallocated. Because `IndexStoreDB` is primarily owned by `UncheckedIndex`, we rely on deallocating this object to save the index store. This is fairly brittle because various parts of the codebase may hold transient references to that object as reported in swiftlang#2455 (comment).

Explicitly remove the reference from `UncheckedIndex` to `IndexStoreDB`. While this still isn’t perfect because other parts of the code base may hold references to `IndexStoreDB` but those should be a lot rarer, resulting in a more consistent closing of the index.
@ahoppen

ahoppen commented Feb 28, 2026

Copy link
Copy Markdown
Member Author

@swift-ci Please test

@ahoppen ahoppen merged commit ce86aae into swiftlang:main Mar 1, 2026
3 checks passed
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.

2 participants