Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.IllegalStateException: Storage for [...] is already registered with 2.0.20-1.0.24 #2072

Open
ychescale9 opened this issue Aug 30, 2024 · 42 comments · Fixed by #2129
Assignees
Labels
bug Something isn't working P1 major features or blocking bugs

Comments

@ychescale9
Copy link

ychescale9 commented Aug 30, 2024

Since updating to 2.0.20-1.0.24 our devs started getting the following occasionally:

java.lang.IllegalStateException: Storage for [path/to/project/my-module/build/kspCaches/debug/symbolLookups/id-to-file.tab] is already registered
	at org.jetbrains.kotlin.com.intellij.util.io.FilePageCache.registerPagedFileStorage(FilePageCache.java:410)
	at org.jetbrains.kotlin.com.intellij.util.io.PagedFileStorage.<init>(PagedFileStorage.java:72)
	at org.jetbrains.kotlin.com.intellij.util.io.ResizeableMappedFile.<init>(ResizeableMappedFile.java:55)
	at org.jetbrains.kotlin.com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:128)
	at org.jetbrains.kotlin.com.intellij.util.io.PersistentEnumerator.createDefaultEnumerator(PersistentEnumerator.java:52)
	at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.<init>(PersistentMapImpl.java:165)
	at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.<init>(PersistentMapImpl.java:140)
	at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapBuilder.buildImplementation(PersistentMapBuilder.java:88)
	at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapBuilder.build(PersistentMapBuilder.java:71)
	at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:45)
	at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:71)
	at org.jetbrains.kotlin.incremental.storage.LazyStorage.createMap(LazyStorage.kt:60)
	at org.jetbrains.kotlin.incremental.storage.LazyStorage.getStorageOrCreateNew(LazyStorage.kt:57)
	at org.jetbrains.kotlin.incremental.storage.LazyStorage.set(LazyStorage.kt:78)
	at org.jetbrains.kotlin.incremental.storage.PersistentStorageWrapper.set(PersistentStorage.kt:94)
	at org.jetbrains.kotlin.incremental.LookupStorage.addFileIfNeeded(LookupStorage.kt:165)
	at org.jetbrains.kotlin.incremental.LookupStorage.addAll$lambda$4(LookupStorage.kt:117)
	at org.jetbrains.kotlin.utils.CollectionsKt.keysToMap(collections.kt:117)
	at org.jetbrains.kotlin.incremental.LookupStorage.addAll(LookupStorage.kt:117)
	at org.jetbrains.kotlin.incremental.BuildUtilKt.update(buildUtil.kt:134)
	at com.google.devtools.ksp.LookupStorageWrapperImpl.update(IncrementalContext.kt:231)
	at com.google.devtools.ksp.common.IncrementalContextBase.updateLookupCache(IncrementalContextBase.kt:133)
	at com.google.devtools.ksp.common.IncrementalContextBase.updateCaches(IncrementalContextBase.kt:364)
	at com.google.devtools.ksp.common.IncrementalContextBase.updateCachesAndOutputs(IncrementalContextBase.kt:470)
	at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:362)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
	at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:75)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze$lambda$12(KotlinToJVMBytecodeCompiler.kt:373)
	at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:112)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:364)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.repeatAnalysisIfNeeded(KotlinToJVMBytecodeCompiler.kt:282)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.runFrontendAndGenerateIrUsingClassicFrontend(KotlinToJVMBytecodeCompiler.kt:195)
	at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.compileModules$cli(KotlinToJVMBytecodeCompiler.kt:106)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:170)
	at org.jetbrains.kotlin.cli.jvm.K2JVMCompiler.doExecute(K2JVMCompiler.kt:43)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:103)
	at org.jetbrains.kotlin.cli.common.CLICompiler.execImpl(CLICompiler.kt:49)
	at org.jetbrains.kotlin.cli.common.CLITool.exec(CLITool.kt:101)
	at org.jetbrains.kotlin.daemon.CompileServiceImpl.compile(CompileServiceImpl.kt:1555)
	at jdk.internal.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:569)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:360)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:712)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:587)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:828)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:705)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:704)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:840)
	Suppressed: java.lang.Exception: Storage[path/to/project/my-module/build/kspCaches/debug/symbolLookups/id-to-file.tab] registration stack trace
		at org.jetbrains.kotlin.com.intellij.util.io.FilePageCache.registerPagedFileStorage(FilePageCache.java:437)
		at org.jetbrains.kotlin.com.intellij.util.io.PagedFileStorage.<init>(PagedFileStorage.java:72)
		at org.jetbrains.kotlin.com.intellij.util.io.ResizeableMappedFile.<init>(ResizeableMappedFile.java:55)
		at org.jetbrains.kotlin.com.intellij.util.io.PersistentBTreeEnumerator.<init>(PersistentBTreeEnumerator.java:128)
		at org.jetbrains.kotlin.com.intellij.util.io.PersistentEnumerator.createDefaultEnumerator(PersistentEnumerator.java:52)
		at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.<init>(PersistentMapImpl.java:165)
		at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapImpl.<init>(PersistentMapImpl.java:140)
		at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapBuilder.buildImplementation(PersistentMapBuilder.java:88)
		at org.jetbrains.kotlin.com.intellij.util.io.PersistentMapBuilder.build(PersistentMapBuilder.java:71)
		at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:45)
		at org.jetbrains.kotlin.com.intellij.util.io.PersistentHashMap.<init>(PersistentHashMap.java:71)
		at org.jetbrains.kotlin.incremental.storage.LazyStorage.createMap(LazyStorage.kt:60)
		at org.jetbrains.kotlin.incremental.storage.LazyStorage.getStorageIfExists(LazyStorage.kt:51)
		at org.jetbrains.kotlin.incremental.storage.LazyStorage.get(LazyStorage.kt:74)
		at org.jetbrains.kotlin.incremental.storage.PersistentStorageWrapper.get(PersistentStorage.kt:90)
		at org.jetbrains.kotlin.incremental.LookupStorage.get(LookupStorage.kt:99)
		at com.google.devtools.ksp.LookupStorageWrapperImpl.get(IncrementalContext.kt:224)
		at com.google.devtools.ksp.common.IncrementalContextBase.calcDirtyFiles(IncrementalContextBase.kt:234)
		at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$2.invoke(KotlinSymbolProcessingExtension.kt:196)
		at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension$doAnalysis$2.invoke(KotlinSymbolProcessingExtension.kt:189)
		at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.handleException(KotlinSymbolProcessingExtension.kt:414)
		at com.google.devtools.ksp.AbstractKotlinSymbolProcessingExtension.doAnalysis(KotlinSymbolProcessingExtension.kt:189)
		at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(TopDownAnalyzerFacadeForJVM.kt:112)
		at org.jetbrains.kotlin.cli.jvm.compiler.TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration$default(TopDownAnalyzerFacadeForJVM.kt:75)
		at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze$lambda$12(KotlinToJVMBytecodeCompiler.kt:373)
		at org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport.analyzeAndReport(AnalyzerWithCompilerReport.kt:112)
		at org.jetbrains.kotlin.cli.jvm.compiler.KotlinToJVMBytecodeCompiler.analyze(KotlinToJVMBytecodeCompiler.kt:364)
		... 24 more

Our workaround has been killing the Kotlin daemons.

Others have experienced the same issue as reported in the kotlinlang slack.

There are reports on both Android and JS projects so doesn't look like it's specific to a target.

We're still on KSP 1.

@AkobirBozorov
Copy link

I am getting this error as well. I managed to put ksp and hilt in my project and now this error. I don't know what to do as i am new developer

@palsega
Copy link

palsega commented Aug 31, 2024

Found out this exception in Android while trying to use Room in project. What I would do is use a tested version, for me 2.0.10-1.0.24 works as expected.

@metinyildiran
Copy link

I've got Room in my project and version 2.0.10-1.0.24 with Kotlin version 2.0.10 also worked for me.

valerii-fr pushed a commit to valerii-fr/Resource_Sharing that referenced this issue Sep 1, 2024
@mohsen2986
Copy link

I've got Room in my project and version 2.0.10-1.0.24 with Kotlin version 2.0.10 also worked for me.

It works for me

@demidenko
Copy link

got this exception after incorrect (or unfinished) automigration in android room. after define manual migration it throw this on build
downgrade to kotlin=2.0.10 and ksp=2.0.10-1.0.24 works fine

demidenko added a commit to demidenko/CPS that referenced this issue Sep 3, 2024
@epool
Copy link

epool commented Sep 3, 2024

for those who face this issue, killing the Kotlin daemons workaround from Slack worked for me:

jps | grep -E 'KotlinCompileDaemon' | awk '{print $1}' | xargs kill -9 || true

Jaehwa-Noh added a commit to Jaehwa-Noh/SSL-AS-Android-D that referenced this issue Sep 4, 2024
@Kevinrob
Copy link

Kevinrob commented Sep 4, 2024

for those who face this issue, killing the Kotlin daemons workaround from Slack worked for me:

jps | grep -E 'KotlinCompileDaemon' | awk '{print $1}' | xargs kill -9 || true

Or just ./gradlew --stop 👍

@ting-yuan ting-yuan self-assigned this Sep 4, 2024
@ting-yuan ting-yuan added bug Something isn't working P1 major features or blocking bugs labels Sep 4, 2024
@ting-yuan
Copy link
Collaborator

Looks similar to #2042, where kspCache is left in an illegal state. Let's see if this persists after the fix to #2042 has landed.

@ting-yuan
Copy link
Collaborator

KSP 2.0.20-1.0.25 is just released and may have fixed this issue. Would you mind to give it a try?

@thejufo
Copy link

thejufo commented Sep 5, 2024

KSP 2.0.20-1.0.25 is just released and may have fixed this issue. Would you mind to give it a try?

Unfortunately, I can confirm that the issue still persists in KSP 2.0.20-1.0.25

@bitspittle
Copy link
Contributor

@ychescale9 how come you closed this issue if @thejufo was able to reproduce it with the latest ksp release?

@ychescale9
Copy link
Author

sorry, re-opened

@ychescale9 ychescale9 reopened this Sep 6, 2024
@metinyildiran
Copy link

metinyildiran commented Sep 6, 2024

KSP 2.0.20-1.0.25 is just released and may have fixed this issue. Would you mind to give it a try?

It fixed the issue for me. I've cleaned the project and tried with Kotlin version 2.0.20.

@palsega
Copy link

palsega commented Sep 6, 2024

I noticed before it was an issue but now I confirm that with version 2.0.20-1.0.25 everything works. Just rebuilding the project even without its cleaning.

@alxgord
Copy link

alxgord commented Sep 7, 2024

I confirm that after updating ksp to 2.0.20-1.0.25 and invalidating the cache the build was successful

@hoangchungk53qx1
Copy link

after updating ksp to 2.0.20-1.0.25 , it works , try to delete build folder and rebuilding the project

@bitspittle
Copy link
Contributor

@ychescale9 looks like people are saying it's resolved for them, so maybe it's ok to close it after all!

Fwiw I've been using latest KSP since yesterday without issue, although I never used the previous version that people were complaining about so I wasn't 100% sure if my experience mattered.

@asapha
Copy link
Contributor

asapha commented Sep 10, 2024

It still happens when compiling after a processor raised an exception.
Repro if it helps:

# A project with a sample using its own processor
git clone https://github.com/r0adkll/kimchi.git
cd kimchi

# Add invalid code from the processor's point of view
echo "@com.r0adkll.kimchi.annotations.ContributesBinding(com.r0adkll.kimchi.restaurant.common.scopes.AppScope::class) object Test" > sample/desktopApp/src/main/kotlin/com/r0adkll/kimchi/restaurant/di/Test.kt`

# The processor raises its error 
# (here `e: [ksp] KimchiException: Bound implementation must have a single supertype, or specify a 'boundType' if extending more than one supertype.`)
`./gradlew :sample:desktopApp:run`

# Remove the "invalid" code
`rm sample/desktopApp/src/main/kotlin/com/r0adkll/kimchi/restaurant/di/Test.kt`

# The storage error is raised, the kotlin daemon needs to be killed.
`./gradlew :sample:desktopApp:run`

@polivmi1
Copy link

What worked for us is to also kill the daemon (found this in a slack discussion)
jps | grep -E 'KotlinCompileDaemon' | awk '{print $1}' | xargs kill -9 || true

@bamsbamx
Copy link

I am also suffering this with version 2.0.20-1.0.25. In my case using androidx Room in a KMP project. Seems like it starts to throw after a build error happened. For example, I had a non-suspending function in my database DAO, in KMP, Room requires all functions to be suspending, so it threw an error whem building. After that the error mentioned in this issue started to happen.

However, after restarting the IDE (Android Studio) it was fixed

@nico-gonzalez
Copy link

I am also suffering this with version 2.0.20-1.0.25. In my case using androidx Room in a KMP project. Seems like it starts to throw after a build error happened. For example, I had a non-suspending function in my database DAO, in KMP, Room requires all functions to be suspending, so it threw an error whem building. After that the error mentioned in this issue started to happen.

However, after restarting the IDE (Android Studio) it was fixed

same here while changing some classes that caused recompilation of several modules, it's still happening with 2.0.20-1.0.25. In my case doing a ./gradlew --stop fixed it

@IceBlizz6
Copy link

Do you all use file system watching?

I'm using IntelliJ (probably same as many others here).
It's possible that this editor is doing some file system watching without my knowledge.
It is rich with many features so it wouldn't surprise me.

But i don't think i have set up any additional system that would use file system watching, atleast not to my knowledge.

@ansman
Copy link
Contributor

ansman commented Sep 27, 2024

I'm specifically talking about Gradle file system watching

@IceBlizz6
Copy link

Gradle enables file system watching by default for supported operating systems since Gradle 7.

Says that it is enabled by default since Gradle 7 and i'm using 8 so i believe answer is yes in my case atleast.

@enriqueajin
Copy link

got this exception after incorrect (or unfinished) automigration in android room. after define manual migration it throw this on build downgrade to kotlin=2.0.10 and ksp=2.0.10-1.0.24 works fine

Worked perfectly for me. Thanks!

asapha added a commit to asapha/ksp that referenced this issue Sep 29, 2024
@asapha
Copy link
Contributor

asapha commented Sep 29, 2024

I could repro the issue in the google/ksp repository by adding some integrations tests:
main...asapha:ksp:issue-2072 (repo)
One uses an external processor (kotlin-inject) and the other uses a custom one.

Feel free to remix/take inspiration from them

@sonrohan
Copy link

We are also seeing this issue.

@NicosNicolaou16
Copy link

I have the same issue with the version 2.0.20-1.0.25

@aboutZZ
Copy link

aboutZZ commented Oct 1, 2024

Please stop spamming this issue

@raquezha
Copy link

raquezha commented Oct 1, 2024

Worked on version 2.0.20-1.0.25

  1. Run:

jps | grep -E 'KotlinCompileDaemon' | awk '{print $1}' | xargs kill -9 || true

  1. Invalidate Cache and Restart

  2. Run your app

@NicosNicolaou16
Copy link

Worked on version 2.0.20-1.0.25

  1. Run:

jps | grep -E 'KotlinCompileDaemon' | awk '{print $1}' | xargs kill -9 || true

  1. Invalidate Cache and Restart
  2. Run your app

Thank you worked!

@NicosNicolaou16
Copy link

@raquezha yes worked but I changed something on Room Database again reproduce this error, so I'm fixing this issue with "git stash". I did the steps that you wrote on the comment again but not working again

ting-yuan pushed a commit to ting-yuan/ksp that referenced this issue Oct 2, 2024
ting-yuan pushed a commit to ting-yuan/ksp that referenced this issue Oct 2, 2024
github-actions bot pushed a commit that referenced this issue Oct 2, 2024
github-actions bot pushed a commit that referenced this issue Oct 2, 2024
@ychescale9
Copy link
Author

@ting-yuan given the scale of the impact are we planning to do a release with the fix soon?

@hgarciaalberto
Copy link

Same issue on 2.0.21-1.0.25 Storage for [.../app/build/kspCaches/miviaDebug/symbolLookups/id-to-file.tab] is already registered

@ting-yuan
Copy link
Collaborator

2.0.21-1.0.26, which contains the fix, was just released!

@sarimmehdi
Copy link

I am using the latest 2.0.21-1.0.26 version and I still get this error after modifying one of the Type Converters for the Room Database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P1 major features or blocking bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.