[GRADLE-2032] Concurrent builds with a buildSrc project cause a timeout on the cache directory Created: 06/Jan/12  Updated: 04/Jan/13  Resolved: 17/Jul/12

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-7
Fix Version/s: 1.1-rc-1

Type: Bug
Reporter: Rolf Suurd Assignee: Unassigned
Resolution: Fixed Votes: 9

Attachments: Zip Archive minimal.zip    

 Description   

When trying to run a second build of my project when another build is already running, gradle will wait and eventually time out locking the cache in the buildSrc project.

I have included a trivial project which demonstrates the problem.
Running gradle jettyRun, followed by a gradle jettyStop in another terminal, the second gradle instance will timeout with the following stacktrace:

FAILURE: Build failed with an exception.

  • What went wrong:
    Could not open cache directory buildSrc (D:\prg\projects\example\buildSrc\.gradle\noVersion\buildSrc).
    Cause: Timeout waiting to lock cache directory buildSrc (D:\prg\projects\example\buildSrc\.gradle\noVersion\buildSrc). It is currently in use by another Gradle instance.
    Owner PID: 6896
    Our PID: 7076
    Owner Operation:
    Our operation:
    Lock file: D:\prg\projects\example\buildSrc\.gradle\noVersion\buildSrc\cache.properties.lock
  • Try:
    Run with --info or --debug option to get more log output.
  • Exception is:
    org.gradle.cache.CacheOpenException: Could not open cache directory buildSrc (D:\prg\projects\example\buildSrc\.gradle\noVersion\buildSrc).
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:53)
    at org.gradle.cache.internal.DefaultCacheFactory$CacheFactoryImpl.doOpenDir(DefaultCacheFactory.java:62)
    at org.gradle.cache.internal.DefaultCacheFactory$CacheFactoryImpl.openStateCache(DefaultCacheFactory.java:105)
    at org.gradle.cache.internal.DefaultCacheRepository$StateCacheBuilder.doOpen(DefaultCacheRepository.java:226)
    at org.gradle.cache.internal.DefaultCacheRepository$StateCacheBuilder.doOpen(DefaultCacheRepository.java:219)
    at org.gradle.cache.internal.DefaultCacheRepository$AbstractCacheBuilder.open(DefaultCacheRepository.java:113)
    at org.gradle.initialization.BuildSourceBuilder.createBuildSourceClasspath(BuildSourceBuilder.java:86)
    at org.gradle.initialization.BuildSourceBuilder.buildAndCreateClassLoader(BuildSourceBuilder.java:57)
    at org.gradle.initialization.SettingsHandler.findSettingsAndLoadIfAppropriate(SettingsHandler.java:84)
    at org.gradle.initialization.SettingsHandler.findAndLoadSettings(SettingsHandler.java:46)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:108)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:76)
    at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
    at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
    at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
    at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:238)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:222)
    at org.gradle.launcher.Main.doAction(Main.java:48)
    at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
    at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
    at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
    at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
    at org.gradle.launcher.Main.main(Main.java:39)
    at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
    at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
    Caused by: org.gradle.cache.internal.LockTimeoutException: Timeout waiting to lock cache directory buildSrc (D:\prg\projects\example\buildSrc\.gradle\noVersion\buildSrc). It is currently in use by another Gradle instance.
    Owner PID: 6896
    Our PID: 7076
    Owner Operation:
    Our operation:
    Lock file: D:\prg\projects\example\buildSrc\.gradle\noVersion\buildSrc\cache.properties.lock
    at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.lock(DefaultFileLockManager.java:232)
    at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.<init>(DefaultFileLockManager.java:98)
    at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:68)
    at org.gradle.cache.internal.DefaultFileLockManager.lock(DefaultFileLockManager.java:56)
    at org.gradle.cache.internal.DefaultCacheAccess.open(DefaultCacheAccess.java:75)
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:45)
    ... 27 more


 Comments   
Comment by Daz DeBoer [ 07/Jan/12 ]

This looks very much like http://issues.gradle.org/browse/GRADLE-2020, which we believe was fixed in M7. Can you confirm that you're using the Milestone7 release?

Comment by Adam Murdoch [ 07/Jan/12 ]

@daz, it's a different problem, with the same symptom. It looks like BuildSourceBuilder is (indirectly) locking the buildSrc directory with an exclusive lock.

Comment by Detlef Brendle [ 28/Feb/12 ]

I face the same problem with Milestone-8

  • Exception is:
    org.gradle.cache.CacheOpenException: Could not open cache directory buildSrc project/buildSrc/.gradle/noVersion/buildSrc).
    at org.gradle.cache.internal.DefaultPersistentDirectoryStore.open(DefaultPersistentDirectoryStore.java:53)
    at org.gradle.cache.internal.DefaultCacheFactory$CacheFactoryImpl.doOpenDir(DefaultCacheFactory.java:62)
    at org.gradle.cache.internal.DefaultCacheFactory$CacheFactoryImpl.openStateCache(DefaultCacheFactory.java:105)
    at org.gradle.cache.internal.DefaultCacheRepository$StateCacheBuilder.doOpen(DefaultCacheRepository.java:226)
    at org.gradle.cache.internal.DefaultCacheRepository$StateCacheBuilder.doOpen(DefaultCacheRepository.java:219)
    at org.gradle.cache.internal.DefaultCacheRepository$AbstractCacheBuilder.open(DefaultCacheRepository.java:113)
    at org.gradle.initialization.BuildSourceBuilder.createBuildSourceClasspath(BuildSourceBuilder.java:86)
    at org.gradle.initialization.BuildSourceBuilder.buildAndCreateClassLoader(BuildSourceBuilder.java:57)
    at org.gradle.initialization.SettingsHandler.findSettingsAndLoadIfAppropriate(SettingsHandler.java:83)
    at org.gradle.initialization.SettingsHandler.findAndLoadSettings(SettingsHandler.java:45)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:131)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:110)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:78)
    at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:42)
    at org.gradle.launcher.cli.RunBuildAction.execute(RunBuildAction.java:28)
    at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:32)
    at org.gradle.launcher.exec.ExceptionReportingAction.execute(ExceptionReportingAction.java:21)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:238)
    at org.gradle.launcher.cli.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:222)
    at org.gradle.launcher.Main.doAction(Main.java:48)
    at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:53)
    at org.gradle.launcher.exec.EntryPoint$1.execute(EntryPoint.java:51)
    at org.gradle.launcher.exec.Execution.execute(Execution.java:28)
    at org.gradle.launcher.exec.EntryPoint.run(EntryPoint.java:39)
    at org.gradle.launcher.Main.main(Main.java:39)
    at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:51)
    at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:33)
    at org.gradle.launcher.GradleMain.main(GradleMain.java:24)

Any news by when this is fixed ?

Thanks,
detlef

Comment by Shorn Tolley [ 24/Apr/12 ]

Appears to be happening with 1.0-rc-1 and 1.0-rc-2 as well.
Can easily be produced with a completely empty script with nothing more than "apply plugin: 'jetty'".

Comment by Simon McClenahan [ 17/May/12 ]

I have worked around the issue by deleting the buildSrc directory.

Comment by phil swenson [ 24/May/12 ]

Is this going to be fixed for the release?

Comment by Anton [ 10/Jul/12 ]

An ability to launch several instances of gradle with different tasks is very important for us and is not so exotic as it may seem.
Typical usecase is to launch server and client (or any other project components):

gradle jettyRun
gradle runClient

or more complex:

gradle startFrontend
gradle startBackend1
gradle startBackend2
gradle runClient

We use this feature extensively and this issue blocks us from moving from 0.9.2 to 1.0.

Generated at Wed Jun 30 12:10:56 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.