apache / apache/maven-mvnd

`Could not acquire write lock for…` errors

Open
#836 37 comments 2 reactions 0 assignees View on GitHub
discussion not a bug
Dominant language
Java
Stars
3.5k
Forks
250
Avg merge
16h 22m
Merged PRs (30d)
36

Description

I just upgraded mvnd to 1.0-m6-m39 via Snap from 0.9.0 (using Java 11) and ran a build of my reactor with 27 modules as usual (max parallelism 11). It spat out some errors such as

```
Could not acquire write lock for '~/.m2/repository/.locks/com.github.spotbugs~spotbugs-annotations~4.7.3.lock'
Could not acquire write lock for '~/.m2/repository/.locks/commons-collections~commons-collections~3.2.2.lock'
```

and the build failed partway through

```
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0:enforce (enforce-bytecode-version) on project …: Execution enforce-bytecode-version of goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0:enforce failed: Could not acquire write lock for '~/.m2/repository/.locks/groupId~artifactId~1.234.lock' -> [Help 1]
Failed to execute goal some:plugin:1.2:some-mojo (default-some-mojo) on project …: Execution default-some-mojo of goal some:plugin:1.2:some-mojo failed: Could not acquire write lock for '~/.m2/repository/.locks/groupId2~artifactId2~5.678.lock' -> [Help 1]
Could not acquire write lock for '~/.m2/repository/.locks/groupId3~artifactId3~9.012.lock'
```

When I ran the build again, it passes, so I presume this was some sort of race condition, possibly involving artifact downloads (I had pulled in various POM updates since the last local build of the project).

No further details were provided, and I was not using `-e` so there was no stack trace giving context. I checked `~/.m2/mvnd/registry/1.0-m6/daemon-*.log` which did not really add any more information:

```
Dispatch message: ExecutionFailure{projectId='…', halted=true, exception='java.lang.IllegalStateException: Could not acquire write lock for '~/.m2/repository/.locks/com.github.spotbugs~spotbugs-annotations~4.7.3.lock''}
```

If nothing else, the `Throwable.toString` of the cause ought to be included in the top-level error message I think.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the daemon failure record in ~/.m2/mvnd/registry/1.0-m6/daemon-*.log and reproduce the build with -e to obtain the missing stack trace; no source file or test is named in the report. Trace the lock-acquisition failure behind the reported IllegalStateException and ensure the top-level error exposes the cause's Throwable.toString.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.