#2112·serena

Kotlin LSP fallback storage directory (concurrent-instance case, #1982) is never removed

Author: AmirF194Created Sep 27, 2026Updated Sep 27, 2026

DependencyProvider._claim_storage_dir in src/solidlsp/language_servers/kotlin_language_server.py falls back to a per-process directory ({project_cache_dir}-instance-{pid}) when the shared, deterministic storage directory is already locked by another concurrent Serena instance (the case #1982 added support for). That fallback directory holds its own copy of the Kotlin LSP's IntelliJ-platform index, several MB in size.

Nothing ever removes it. release_storage_lock only releases self._storage_lock, which stays None on the fallback path (a FileLock object is only ever assigned on the primary, deterministic path), so the release is a no-op there. KotlinLanguageServer.stop() calls only release_storage_lock(), so the fallback directory is never cleaned up anywhere in the object's lifecycle.

Reproduction (no live Kotlin LSP needed, just the dependency-provider logic in isolation):

python
from solidlsp.language_servers.kotlin_language_server import KotlinLanguageServer
from solidlsp.settings import SolidLSPSettings
import os, tempfile

with tempfile.TemporaryDirectory() as tmp:
    def make():
        return KotlinLanguageServer.DependencyProvider(
            custom_settings=SolidLSPSettings.CustomLSSettings({}),
            ls_resources_dir=tmp,
            project_cache_dir=os.path.join(tmp, "project-cache"),
        )
    first = make()
    second = make()
    print("fallback dir exists before release:", os.path.isdir(second.storage_dir))
    second.release_storage_lock()
    print("fallback dir exists after release: ", os.path.exists(second.storage_dir))
    first.release_storage_lock()

Output on current main (7a296833):

fallback dir exists before release: True
fallback dir exists after release:  True

Every concurrent-instance lock collision leaks one of these directories permanently; a workflow that regularly runs multiple concurrent Serena sessions on the same project (explicitly supported since #1982) accumulates them without bound.