[ 
https://issues.apache.org/jira/browse/MNG-7868?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17873714#comment-17873714
 ] 

Daniel Johnson commented on MNG-7868:
-------------------------------------

Ok, so looking at [https://maven.apache.org/resolver/configuration.html,] the 
default http request timeout is 30 minutes
{noformat}
aether.transport.http.requestTimeout=180000{noformat}

And the default lock timeout is 30 seconds
{noformat}
aether.syncContext.named.time=30
aether.syncContext.named.time.unit="SECONDS"{noformat}

So as you confirmed above, a slow request could cause the lock timeout.  I plan 
to experiment by increasing the lock timeout, or reducing the request timeout, 
or both, to see if that explains some of the failures I have seen.  

I don't really understand the full history of the resolver locks, but I do see 
that Maven 3.8.8, which does not face this issue,  uses Resolver 1.6.3 
(https://github.com/apache/maven/blob/maven-3.8.x/pom.xml#L67). And I see that 
the lock timeout parameters were introduced in Resolver 1.7.0.  So it is 
starting to explain why all Maven 3.9.x versions are prone to this issue, since 
it updated to Resolver 1.9.x 
([https://github.com/apache/maven/blob/maven-3.9.0/pom.xml#L145,] now to 1.9.22 
in latest maven-3.9.x branch).

If configuring a higher timeout does prevent the lock issue in the case of slow 
requests, then I guess my question is whether the default lock timeout should 
be higher than the default request timeout, so that a very slow request 
actually fails with a request timeout error message, instead of a cryptic error 
message about failing to acquire lock?

> "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)

Reply via email to