[ https://issues.apache.org/jira/browse/MNG-7868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17869448#comment-17869448 ]
Daniel Johnson edited comment on MNG-7868 at 7/29/24 7:47 PM: -------------------------------------------------------------- I set out to get a shareable project that can reproduce this. I messed up as I was creating it, but I did still in fact hit the issue, so I am going to share the project as-is when issue was hit. This is a simple multi-module project. The aggregator is set also as the parent, and declares a few common dependencies. There are 4 modules, modules 1-3 are just inheriting the dependencies of the parent POM. Module4 is also inheriting, but also declares dependencies to modules 2 and 3. I ran the build with `mvn clean install -T 5` The reason the project is messed up, the `jetty-webapp` and `jetty-servlets` dependencies don't actually exist in version 12.0.11, which triggers its own failure; {noformat} org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project org.apache.maven:module1:jar:0.1-SNAPSHOT dependency: org.eclipse.jetty:jetty-webapp:jar:12.0.11 (compile){noformat} However, in this example I did hit the lock issue, and I hope it may be easier with these open-source dependencies to identify what and where the code is going wrong. {noformat} 12:17:58.290 [mvn-builder-module2] [INFO] Diagnostic dump of lock factory 12:17:58.290 [mvn-builder-module2] [INFO] =============================== 12:17:58.290 [mvn-builder-module2] [INFO] Implementation: org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory 12:17:58.290 [mvn-builder-module2] [INFO] Active locks: 1 12:17:58.291 [mvn-builder-module2] [INFO] 12:17:58.291 [mvn-builder-module2] [INFO] Name: artifact:org.eclipse.jetty:jetty-webapp:12.0.11 12:17:58.291 [mvn-builder-module2] [INFO] RefCount: 2 12:17:58.291 [mvn-builder-module2] [INFO] Thread[mvn-builder-module2,5,main] -> [exclusive] 12:17:58.291 [mvn-builder-module2] [INFO] Thread[mvn-builder-module3,5,main] -> [wait-exclusive] 12:17:58.291 [mvn-builder-module2] [INFO] Thread[mvn-builder-module1,5,main] -> [] 12:17:58.291 [mvn-builder-module2] [INFO] Downloading from internal-repo: https://<our_internal_repo>/mirror-repo/org/eclipse/jetty/jetty-client/12.0.11/jetty-client-12.0.11.pom 12:17:58.291 [mvn-builder-module3] [INFO] Diagnostic dump of lock factory 12:17:58.291 [mvn-builder-module3] [INFO] =============================== 12:17:58.291 [mvn-builder-module3] [INFO] Implementation: org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory 12:17:58.291 [mvn-builder-module3] [INFO] Active locks: 2 12:17:58.291 [mvn-builder-module3] [INFO] 12:17:58.291 [mvn-builder-module3] [INFO] Name: artifact:org.eclipse.jetty:jetty-webapp:12.0.11 12:17:58.291 [mvn-builder-module3] [INFO] RefCount: 1 12:17:58.292 [mvn-builder-module3] [INFO] Thread[BuilderThread 2,5,] -> [] 12:17:58.292 [mvn-builder-module3] [INFO] Thread[mvn-builder-module3,5,main] -> [exclusive] 12:17:58.292 [mvn-builder-module3] [INFO] Thread[mvn-builder-module1,5,main] -> [] 12:17:58.292 [mvn-builder-module3] [INFO] Name: artifact:org.eclipse.jetty:jetty-client:12.0.11 12:17:58.292 [mvn-builder-module3] [INFO] RefCount: 1 12:17:58.292 [mvn-builder-module3] [INFO] Thread[mvn-builder-module1,5,main] -> [exclusive] ... java.lang.IllegalStateException: Attempt 1: Could not acquire write lock for 'artifact:org.eclipse.jetty:jetty-webapp:12.0.11' in 30 SECONDS{noformat} Unfortunately I could not easily reproduce even if deleting my local maven repo and building again and again. Attached is the sample project, as well as full build logs when built with Maven 3.9.8 and Java 8 [^MNG-7868-reproduce.txt] [^MNG-7868.zip] was (Author: hankolerd): I set out to get a shareable project that can reproduce this. I messed up as I was creating it, but I did still in fact hit the issue, so I am going to share the project as-is when issue was hit. This is a simple multi-module project. The aggregator is set also as the parent, and declares a few common dependencies. There are 4 modules, modules 1-3 are just inheriting the dependencies of the parent POM. Module4 is also inheriting, but also declares dependencies to modules 2 and 3. I ran the build with `mvn clean install -T 5` The reason the project is messed up, the `jetty-webapp` and `jetty-servlets` dependencies don't actually exist in version 12.0.11, which triggers its own failure; {noformat} org.apache.maven.project.DependencyResolutionException: Could not resolve dependencies for project org.apache.maven:module1:jar:0.1-SNAPSHOT dependency: org.eclipse.jetty:jetty-webapp:jar:12.0.11 (compile){noformat} However, in this example I did hit the lock issue, and I hope it may be easier with these open-source dependencies to identify what and where the code is going wrong. {noformat} 12:17:58.290 [mvn-builder-module2] [INFO] Diagnostic dump of lock factory 12:17:58.290 [mvn-builder-module2] [INFO] =============================== 12:17:58.290 [mvn-builder-module2] [INFO] Implementation: org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory 12:17:58.290 [mvn-builder-module2] [INFO] Active locks: 1 12:17:58.291 [mvn-builder-module2] [INFO] 12:17:58.291 [mvn-builder-module2] [INFO] Name: artifact:org.eclipse.jetty:jetty-webapp:12.0.11 12:17:58.291 [mvn-builder-module2] [INFO] RefCount: 2 12:17:58.291 [mvn-builder-module2] [INFO] Thread[mvn-builder-module2,5,main] -> [exclusive] 12:17:58.291 [mvn-builder-module2] [INFO] Thread[mvn-builder-module3,5,main] -> [wait-exclusive] 12:17:58.291 [mvn-builder-module2] [INFO] Thread[mvn-builder-module1,5,main] -> [] 12:17:58.291 [mvn-builder-module2] [INFO] Downloading from internal-repo: https://<our_internal_repo>/mirror-repo/org/eclipse/jetty/jetty-client/12.0.11/jetty-client-12.0.11.pom 12:17:58.291 [mvn-builder-module3] [INFO] Diagnostic dump of lock factory 12:17:58.291 [mvn-builder-module3] [INFO] =============================== 12:17:58.291 [mvn-builder-module3] [INFO] Implementation: org.eclipse.aether.named.providers.LocalReadWriteLockNamedLockFactory 12:17:58.291 [mvn-builder-module3] [INFO] Active locks: 2 12:17:58.291 [mvn-builder-module3] [INFO] 12:17:58.291 [mvn-builder-module3] [INFO] Name: artifact:org.eclipse.jetty:jetty-webapp:12.0.11 12:17:58.291 [mvn-builder-module3] [INFO] RefCount: 1 12:17:58.292 [mvn-builder-module3] [INFO] Thread[BuilderThread 2,5,] -> [] 12:17:58.292 [mvn-builder-module3] [INFO] Thread[mvn-builder-module3,5,main] -> [exclusive] 12:17:58.292 [mvn-builder-module3] [INFO] Thread[mvn-builder-module1,5,main] -> [] 12:17:58.292 [mvn-builder-module3] [INFO] Name: artifact:org.eclipse.jetty:jetty-client:12.0.11 12:17:58.292 [mvn-builder-module3] [INFO] RefCount: 1 12:17:58.292 [mvn-builder-module3] [INFO] Thread[mvn-builder-module1,5,main] -> [exclusive] ... java.lang.IllegalStateException: Attempt 1: Could not acquire write lock for 'artifact:org.eclipse.jetty:jetty-webapp:12.0.11' in 30 SECONDS{noformat} Unfortunately I could not easily reproduce even if deleting my local maven repo and building again and again. [^MNG-7868-reproduce.txt] [^MNG-7868.zip] > "Could not acquire lock(s)" error in concurrent maven builds > ------------------------------------------------------------ > > Key: MNG-7868 > URL: https://issues.apache.org/jira/browse/MNG-7868 > Project: Maven > Issue Type: Bug > Environment: windows, maven 3.9.4 > Reporter: Jörg Hohwiller > Priority: Major > Attachments: MNG-7868-pz_ai_37_lock.txt, MNG-7868-reproduce.txt, > MNG-7868.zip, image-2024-04-10-15-44-37-013.png, screenshot-1.png > > > {code} > [ERROR] Failed to execute goal > org.apache.maven.plugins:maven-install-plugin:3.1.1:install (default-install) > on project foo.bar: Execution default-install of goal > org.apache.maven.plugins:maven-install-plugin:3.1.1:install failed: Could not > acquire lock(s) -> [Help 1] > {code} > I am using maven 3.9.4 on windows: > {code} > $ mvn -v > Apache Maven 3.9.4 (dfbb324ad4a7c8fb0bf182e6d91b0ae20e3d2dd9) > Maven home: D:\projects\test\software\mvn > Java version: 17.0.5, vendor: Eclipse Adoptium, runtime: > D:\projects\test\software\java > Default locale: en_US, platform encoding: UTF-8 > OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows" > {code} > I searched for this bug and found issues like MRESOLVER-332 that first look > identical or similar but do not really seem to be related so I decided to > create this issue. > For this bug I made the following observations: > * it only happens with concurrent builds: {{mvn -T ...}} > * is seems to be windows related (at least mainly happens on windows) > * it is in-deterministic and is not so easy to create an isolated and simple > project and a reproducible scenario that always results in this error. > However, I get this very often in my current project with many modules (500+). > * it is not specific to the maven-install-plugin and also happens from other > spots in maven: > I also got this stacktrace: > {code} > Suppressed: java.lang.IllegalStateException: Attempt 1: Could not acquire > write lock for > 'C:\Users\hohwille\.m2\repository\.locks\artifact~com.caucho~com.springsource.com.caucho~3.2.1.lock' > in 30 SECONDS > at > org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapter$AdaptedLockSyncContext.acquire > (NamedLockFactoryAdapter.java:202) > at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve > (DefaultArtifactResolver.java:271) > at > org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts > (DefaultArtifactResolver.java:259) > at > org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveDependencies > (DefaultRepositorySystem.java:352) > {code} > See also this related discussion: > https://github.com/apache/maven-mvnd/issues/836#issuecomment-1702488377 -- This message was sent by Atlassian Jira (v8.20.10#820010)