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

Deadlock involving WorkspaceCache.getInstance() #7333

Closed
rsauciuc opened this issue Apr 6, 2024 · 1 comment · Fixed by #7385
Closed

Deadlock involving WorkspaceCache.getInstance() #7333

rsauciuc opened this issue Apr 6, 2024 · 1 comment · Fixed by #7385
Assignees
Labels
Milestone

Comments

@rsauciuc
Copy link

rsauciuc commented Apr 6, 2024

We're receiving reports from Android Studio Iguana stable versions about deadlocks with the following traces:

1. Action Updater (Common)[ApplicationImpl pooled thread 6]

...
com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:218) [59000ms]
com.intellij.util.concurrency.BoundedTaskExecutor$1$$Lambda$769/0x0000000100867018.run(Unknown Source) [59000ms]
com.intellij.util.concurrency.BoundedTaskExecutor$1.executeFirstTaskAndHelpQueue(BoundedTaskExecutor.java:227) [59000ms]
com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:31) [59000ms]
com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:249) [59000ms]
io.opentelemetry.context.Context$$Lambda$1294/0x0000000100dfba48.run(Unknown Source) [59000ms]
io.opentelemetry.context.Context.lambda$wrap$1(Context.java:212) [59000ms]
com.intellij.openapi.actionSystem.impl.ActionUpdater$$Lambda$1293/0x0000000100dfb7f8.run(Unknown Source) [59000ms]
com.intellij.openapi.actionSystem.impl.ActionUpdater.lambda$doExpandActionGroupAsync$17(ActionUpdater.java:402) [59000ms]
com.intellij.openapi.progress.util.BackgroundTaskUtil.runUnderDisposeAwareIndicator(BackgroundTaskUtil.java:360) [59000ms]
...
com.intellij.openapi.application.impl.ApplicationImpl.tryRunReadAction(ApplicationImpl.java:1133) [59000ms]
...
com.intellij.openapi.actionSystem.impl.ActionUpdater.doUpdate(ActionUpdater.java:740) [59000ms]
com.intellij.openapi.actionSystem.ex.ActionUtil.performDumbAwareUpdate(ActionUtil.java:182) [59000ms]
com.intellij.openapi.actionSystem.ex.ActionUtil$$Lambda$1196/0x0000000100d1a000.run(Unknown Source) [59000ms]
com.intellij.openapi.actionSystem.ex.ActionUtil.lambda$performDumbAwareUpdate$0(ActionUtil.java:159) [59000ms]
io.flutter.actions.DeviceSelectorAction.update(DeviceSelectorAction.java:64) [59000ms]
io.flutter.actions.DeviceSelectorAction.isSelectorVisible(DeviceSelectorAction.java:152) [59000ms]
io.flutter.run.daemon.DeviceService.getInstance(DeviceService.java:60) [59000ms]
com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:630) [59000ms]
com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:676) [59000ms]
com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:94) [59000ms]
com.intellij.serviceContainer.BaseComponentAdapter.createInstance(BaseComponentAdapter.kt:137) [59000ms]
com.intellij.serviceContainer.BaseComponentAdapter.doCreateInstance(BaseComponentAdapter.kt:158) [59000ms]
com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:43) [59000ms]
com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:47) [59000ms]
com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:1011) [59000ms]
com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:95) [59000ms]
java.base@17.0.9/java.lang.reflect.Constructor.newInstance(Constructor.java:480) [59000ms]
java.base@17.0.9/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) [59000ms]
java.base@17.0.9/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [59000ms]
java.base@17.0.9/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) [59000ms]
java.base@17.0.9/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [59000ms]
io.flutter.run.daemon.DeviceService.<init>(DeviceService.java:86) [59000ms]
io.flutter.bazel.WorkspaceCache.getInstance(WorkspaceCache.java:83) [59000ms]
com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:630) [59000ms]
com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:676) [59000ms]
com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:105) [59000ms]
java.base@17.0.9/java.lang.Thread.sleep(Native Method) [59000ms]

2. ApplicationImpl pooled thread 7

java.base@17.0.9/java.util.concurrent.FutureTask.run(FutureTask.java:264) [59000ms]
java.base@17.0.9/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) [59000ms]
io.flutter.utils.Refreshable$$Lambda$2006/0x000000010142fc68.run(Unknown Source) [59000ms]
io.flutter.utils.Refreshable.runInBackground(Refreshable.java:223) [59000ms]
io.flutter.run.daemon.DeviceService$$Lambda$2005/0x000000010142fa18.call(Unknown Source) [59000ms]
io.flutter.run.daemon.DeviceService.chooseNextDaemon(DeviceService.java:224) [59000ms]
io.flutter.run.daemon.DeviceDaemon.chooseCommand(DeviceDaemon.java:129) [59000ms]
io.flutter.run.daemon.DeviceDaemon.usesFlutter(DeviceDaemon.java:168) [59000ms]
io.flutter.utils.FlutterModuleUtils.isFlutterBazelProject(FlutterModuleUtils.java:142) [59000ms]
io.flutter.utils.FlutterModuleUtils.getFlutterBazelWorkspace(FlutterModuleUtils.java:125) [59000ms]
io.flutter.bazel.WorkspaceCache.getInstance(WorkspaceCache.java:83) [59000ms]
com.intellij.serviceContainer.ComponentManagerImpl.getService(ComponentManagerImpl.kt:630) [59000ms]
com.intellij.serviceContainer.ComponentManagerImpl.doGetService(ComponentManagerImpl.kt:676) [59000ms]
com.intellij.serviceContainer.BaseComponentAdapter.getInstance(BaseComponentAdapter.kt:94) [59000ms]
com.intellij.serviceContainer.BaseComponentAdapter.createInstance(BaseComponentAdapter.kt:137) [59000ms]
com.intellij.serviceContainer.BaseComponentAdapter.doCreateInstance(BaseComponentAdapter.kt:158) [59000ms]
com.intellij.serviceContainer.ServiceComponentAdapter.doCreateInstance(ServiceComponentAdapter.kt:43) [59000ms]
com.intellij.serviceContainer.ServiceComponentAdapter.createAndInitialize(ServiceComponentAdapter.kt:47) [59000ms]
com.intellij.serviceContainer.ComponentManagerImpl.instantiateClassWithConstructorInjection(ComponentManagerImpl.kt:1011) [59000ms]
com.intellij.serviceContainer.ConstructorInjectionKt.instantiateUsingPicoContainer(constructorInjection.kt:95) [59000ms]
java.base@17.0.9/java.lang.reflect.Constructor.newInstance(Constructor.java:480) [59000ms]
java.base@17.0.9/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) [59000ms]
java.base@17.0.9/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [59000ms]
java.base@17.0.9/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) [59000ms]
java.base@17.0.9/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) [59000ms]
io.flutter.bazel.WorkspaceCache.<init>(WorkspaceCache.java:64) [59000ms]
io.flutter.bazel.WorkspaceCache.refresh(WorkspaceCache.java:133) [59000ms]
io.flutter.bazel.Workspace.loadUncached(Workspace.java:276) [59000ms]
io.flutter.bazel.Workspace.findWorkspaceFile(Workspace.java:383) [59000ms]
com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:907) [59000ms]
com.intellij.openapi.application.impl.ReadMostlyRWLock.startRead(ReadMostlyRWLock.java:128) [58900ms]
com.intellij.openapi.application.impl.ReadMostlyRWLock.waitABit(ReadMostlyRWLock.java:164) [58900ms]
java.base@17.0.9/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252) [58900ms]
java.base@17.0.9/jdk.internal.misc.Unsafe.park(Native Method) [58900ms]

3. AWT-EventQueue-0

java.desktop@17.0.9/java.awt.EventDispatchThread.run(EventDispatchThread.java:92) [59000ms]
java.desktop@17.0.9/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105) [59000ms]
...
com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:79) [59000ms]
com.intellij.openapi.application.impl.ApplicationImpl$4.run(ApplicationImpl.java:478) [59000ms]
com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:861) [59000ms]
com.intellij.openapi.application.TransactionGuardImpl$1.run(TransactionGuardImpl.java:190) [59000ms]
com.intellij.openapi.application.TransactionGuardImpl.access$100(TransactionGuardImpl.java:21) [59000ms]
com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:208) [59000ms]
com.intellij.openapi.project.CancellableLaterEdtInvoker$TrackedEdtActivity.run(CancellableLaterEdtInvoker.java:65) [59000ms]
com.intellij.openapi.project.DumbServiceImpl$DumbTaskListener$$Lambda$1804/0x0000000101350e80.run(Unknown Source) [59000ms]
com.intellij.openapi.project.DumbServiceImpl$DumbTaskListener.afterLastTask$lambda$0(DumbServiceImpl.kt:106) [59000ms]
com.intellij.openapi.project.DumbServiceImpl.access$enterSmartModeIfDumb(DumbServiceImpl.kt:49) [59000ms]
com.intellij.openapi.project.DumbServiceImpl.enterSmartModeIfDumb(DumbServiceImpl.kt:271) [59000ms]
com.intellij.openapi.application.WriteAction.compute(WriteAction.java:97) [59000ms]
com.intellij.openapi.application.impl.ApplicationImpl.runWriteAction(ApplicationImpl.java:1006) [59000ms]
com.intellij.openapi.application.impl.ApplicationImpl.runWriteActionWithClass(ApplicationImpl.java:978) [59000ms]
com.intellij.openapi.application.impl.ApplicationImpl.startWrite(ApplicationImpl.java:1196) [59000ms]
com.intellij.openapi.application.impl.ReadMostlyRWLock.writeLock(ReadMostlyRWLock.java:264) [59000ms]
java.base@17.0.9/java.util.concurrent.locks.LockSupport.parkNanos(LockSupport.java:252) [58900ms]
java.base@17.0.9/jdk.internal.misc.Unsafe.park(Native Method) [58900ms]

It looks like the WorkspaceCache service is performing some heavy initialization requiring a read lock in Workspace.findWorkspaceFile (pooled thread 7), while on another thread there's already a pending initialization request under a read action (pooled thread 6) and meanwhile the UI thread is waiting to launch a write action.

This deadlock accounts for about 10% of freeze times in Iguana.

@jacob314 jacob314 added the bug label Apr 8, 2024
@jacob314 jacob314 added this to the M80 milestone Apr 8, 2024
@jacob314
Copy link
Contributor

jacob314 commented Apr 8, 2024

Fyi @helin24 this is a g3 bazel specific issue.

@jwren jwren added the P1 label Apr 10, 2024
@jwren jwren self-assigned this Apr 10, 2024
jwren added a commit to jwren/flutter-intellij that referenced this issue Apr 23, 2024
…orkspace is computed from WorkspaceCache

This is expected to resolve flutter#7333
jwren added a commit that referenced this issue Apr 23, 2024
…orkspace is computed from WorkspaceCache (#7385)

This is expected to resolve
#7333
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants