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

Parallel invocation of AnalysisFacade fails spuriously in 1.20.0-RC1 #4609

Closed
davidburstrom opened this issue Mar 4, 2022 · 10 comments · Fixed by #4631
Closed

Parallel invocation of AnalysisFacade fails spuriously in 1.20.0-RC1 #4609

davidburstrom opened this issue Mar 4, 2022 · 10 comments · Fixed by #4631

Comments

@davidburstrom
Copy link
Contributor

Expected Behavior

It should be possible to run tests and other scenarios in parallel where AnalysisFacade is invoked.

Observed Behavior

io.github.detekt.tooling.api.UnexpectedError
	at app//io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade$runAnalysis$1.invoke(AnalysisFacade.kt:55)
	at app//io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade$runAnalysis$1.invoke(AnalysisFacade.kt:47)
	at app//io.gitlab.arturbosch.detekt.core.tooling.ProcessingSpecSettingsBridgeKt.withSettings(ProcessingSpecSettingsBridge.kt:26)
	at app//io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade.runAnalysis$detekt_core(AnalysisFacade.kt:47)
	at app//io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade.run(AnalysisFacade.kt:25)
        ...
Caused by: java.lang.RuntimeException: Duplicate registration for EP 'org.jetbrains.kotlin.com.intellij.treeCopyHandler': first in FakeIdForTests, second in FakeIdForTests
	at org.jetbrains.kotlin.com.intellij.openapi.components.ComponentManager.createError(ComponentManager.java:167)
	at org.jetbrains.kotlin.com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.checkThatPointNotDuplicated(ExtensionsAreaImpl.java:235)
	at org.jetbrains.kotlin.com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.registerExtensionPoint(ExtensionsAreaImpl.java:240)
	at org.jetbrains.kotlin.com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.doRegisterExtensionPoint(ExtensionsAreaImpl.java:210)
	at org.jetbrains.kotlin.com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.doRegisterExtensionPoint(ExtensionsAreaImpl.java:189)
	at org.jetbrains.kotlin.com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.doRegisterExtensionPoint(ExtensionsAreaImpl.java:183)
	at org.jetbrains.kotlin.com.intellij.openapi.extensions.impl.ExtensionsAreaImpl.registerExtensionPoint(ExtensionsAreaImpl.java:160)
	at io.github.detekt.parser.DetektPomModel.<init>(DetektPomModel.kt:27)
	at io.github.detekt.parser.KotlinEnvironmentUtilsKt.createKotlinCoreEnvironment(KotlinEnvironmentUtils.kt:56)
	at io.gitlab.arturbosch.detekt.core.settings.EnvironmentFacade$environment$2.invoke(EnvironmentAware.kt:38)
	at io.gitlab.arturbosch.detekt.core.settings.EnvironmentFacade$environment$2.invoke(EnvironmentAware.kt:31)
	at kotlin.SynchronizedLazyImpl.getValue(LazyJVM.kt:74)
	at io.gitlab.arturbosch.detekt.core.settings.EnvironmentFacade.getEnvironment(EnvironmentAware.kt:31)
	at io.gitlab.arturbosch.detekt.core.ProcessingSettings.getEnvironment(ProcessingSettings.kt)
	at io.gitlab.arturbosch.detekt.core.KtTreeCompiler.<init>(KtTreeCompiler.kt:14)
	at io.gitlab.arturbosch.detekt.core.tooling.ParsingStrategyKt$inputPathsToKtFiles$1.invoke(ParsingStrategy.kt:24)
	at io.gitlab.arturbosch.detekt.core.tooling.ParsingStrategyKt$inputPathsToKtFiles$1.invoke(ParsingStrategy.kt:23)
	at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$analyze$filesToAnalyze$1.invoke(Lifecycle.kt:38)
	at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$analyze$filesToAnalyze$1.invoke(Lifecycle.kt:38)
	at io.gitlab.arturbosch.detekt.core.util.PerformanceMonitor.measure(PerformanceMonitor.kt:42)
	at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$DefaultImpls.measure(Lifecycle.kt:34)
	at io.gitlab.arturbosch.detekt.core.tooling.Lifecycle$DefaultImpls.analyze(Lifecycle.kt:38)
	at io.gitlab.arturbosch.detekt.core.tooling.DefaultLifecycle.analyze(Lifecycle.kt:61)
	at io.gitlab.arturbosch.detekt.core.tooling.AnalysisFacade$runAnalysis$1.invoke(AnalysisFacade.kt:48)
	... 47 more

This is quite similar to #2433

Steps to Reproduce

Reproduction could be provided if requested.

Context

I'm trying to execute parallel JUnit tests where AnalysisFacade is being invoked, and it hints that parallel production execution also would fail similarly

Your Environment

  • Version of Detekt used: 1.20.0-RC1
  • Version of Gradle used (if applicable): 7.4
  • Gradle scan link (add --scan option when running the gradle task): N/A
  • Operating System and version: macOS
  • Link to your project (if it's a public repository): N/A
@BraisGabin
Copy link
Member

This is a regression, right?

@davidburstrom
Copy link
Contributor Author

Certainly is :)

@BraisGabin BraisGabin added this to the 1.20.0 milestone Mar 8, 2022
@cortinico
Copy link
Member

I think this might be the root cause:

Reverting that will cause the autoCorrect feature to don't work at all for anyone. I was not able to find a better solution sadly.

@davidburstrom
Copy link
Contributor Author

Why wouldn't you be able to reintroduce the synchronized? To me it looks like that would solve this issue and I don't see why that would cause secondary issues.

@cortinico
Copy link
Member

Why wouldn't you be able to reintroduce the synchronized?

That could work. My gut feeling was that the source of all the pain was a call to getRootArea(). I frankly don't know what's the root cause of the stacktrace you reported. Wrapping with synchronized could work (it was originally removed as we mirrored our setup to the KtLint one).

@davidburstrom
Copy link
Contributor Author

I think in my case, the problem stems from the fact that multiple threads are running DetektPomModel.<init> in parallel.

@BraisGabin
Copy link
Member

@davidburstrom do you have time to create a PR with your proposal to fix this?

@davidburstrom
Copy link
Contributor Author

Yeah, I can take a stab at it, especially since I can repro it locally. How much time do I have before the GA release?

@BraisGabin
Copy link
Member

I don't think we can launch the stable release until this is fixed. So there's not an eta.

@davidburstrom
Copy link
Contributor Author

As far as I can tell, the bug is fixed in 1.20.0-RC2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants