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

File lock problems when running under WSL #755

Open
mxsm opened this issue Dec 20, 2022 · 11 comments
Open

File lock problems when running under WSL #755

mxsm opened this issue Dec 20, 2022 · 11 comments

Comments

@mxsm
Copy link
Member

mxsm commented Dec 20, 2022

Java version

openjdk version "1.8.0_342"
OpenJDK Runtime Environment (build 1.8.0_342-8u342-b07-0ubuntu1~20.04-b07)
OpenJDK 64-Bit Server VM (build 25.342-b07, mixed mode)
root@GZYZFA00088591:~/rocketmq#

mvnd version

mvnd 0.8.2 linux-amd64 native client (2bba2d6a4d3a5012ddf9f1f42a22784cad4011e3)
Terminal: org.jline.terminal.impl.PosixSysTerminal with pty org.jline.terminal.impl.jansi.linux.LinuxNativePty
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: /root/maven-mvnd-0.8.2-linux-amd64/mvn
Java version: 1.8.0_342, vendor: Private Build, runtime: /usr/lib/jvm/java-8-openjdk-amd64/jre
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.10.16.3-microsoft-standard-wsl2", arch: "amd64", family: "unix"

image

@ppalaga
Copy link
Contributor

ppalaga commented Dec 20, 2022

I am not sure mvnd is known to work on WSL at all. @gnodet do you happen to know?

Is there any stacktrace of you add -e to the mvnd command?

@mxsm
Copy link
Member Author

mxsm commented Dec 20, 2022

Hi @ppalaga
image

@ppalaga
Copy link
Contributor

ppalaga commented Dec 20, 2022

Are there maybe some logs in ~/.m2/mvnd/registry/0.8.2/?

@mxsm
Copy link
Member Author

mxsm commented Dec 20, 2022

@ppalaga
I encountered the following problem when using mvnd to compile the RocketMQ project on the Windows platform.

mvnd 0.8.2 windows-amd64 native client (2bba2d6a4d3a5012ddf9f1f42a22784cad4011e3)
Terminal: org.jline.terminal.impl.jansi.win.JansiWinSysTerminal
Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63)
Maven home: D:\devtools\maven-mvnd-0.8.2-windows-amd64\mvn
Java version: 1.8.0_202, vendor: Oracle Corporation, runtime: D:\Java\jdk1.8.0_202\jre
Default locale: zh_CN, platform encoding: GBK
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

image

if use mvn -Prelease-all -DskipTests clean install -U not problem

@mxsm
Copy link
Member Author

mxsm commented Dec 20, 2022

@ppalaga

17:49:18.818 D Initializing daemon with properties:
     mvnd.home=/root/maven-mvnd-0.8.2-linux-amd64
     jdk.java.options=--add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/sun.net.www.protocol.jar=ALL-UNNAME
D --add-opens java.base/sun.nio.fs=ALL-UNNAMED
     mvnd.noDaemon=false
     mvnd.debug=false
     mvnd.idleTimeout=3h
     mvnd.keepAlive=100ms
     mvnd.extClasspath=
     mvnd.coreExtensions=
     mvnd.enableAssertions=false
     mvnd.expirationCheckDelay=10s
     mvnd.duplicateDaemonGracePeriod=10s
     mvnd.socketFamily=inet

17:49:18.821 I Daemon started
17:49:18.822 D daemon is running. Sleeping until state changes.
17:49:18.841 I Client connected
17:49:18.854 I Waiting for request
17:49:18.857 I Request received: BuildRequest{args=[-e, -Prelease-all, -DskipTests, -Dquickly, clean, install, -U, -Dstyle.color=always, -T, 11, -b, smart, -Dmvnd.terminalWidth=209], workingDir='/root/rocketmq
', projectDir='/root/rocketmq', env='{PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/d/Java/jdk-17.0.5/bin:/mnt/d/VMware/VMware Workstation/bin/:/mnt/c/Progr
am Files/Common Files/Oracle/Java/javapath:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerS
hell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/d/Git/cmd:/mnt/d/devtools/apache-maven-3.8.6/bin:/mnt/d/devtools/gradle-5.2.1/bin:/mnt/d/cmder:/mnt/d
/Java/jdk-17.0.5/jre/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/d/devtools/maven-mvnd-0.8.2-wi
ndows-amd64/bin:/mnt/d/nodejs/:/mnt/d/Go/bin:/mnt/c/Program Files/dotnet/:/mnt/d/TortoiseGit/bin:/mnt/d/bazel:/mnt/c/Users/liujianbo/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/liujianbo/AppData/Local/Git
HubDesktop/bin:/mnt/c/Users/liujianbo/AppData/Roaming/npm:/mnt/c/Users/liujianbo/go/bin:/mnt/c/Users/liujianbo/AppData/Local/JetBrains/Toolbox/scripts:/snap/bin:/usr/local/go/bin:/root/maven-mvnd-0.8.2-linux-a
md64/bin, WT_SESSION=763e228b-a583-4ea2-9fcd-cb4622a4f75a, LESSCLOSE=/usr/bin/lesspipe %s %s, LESSOPEN=| /usr/bin/lesspipe %s, SHELL=/bin/bash, XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop,
 WSL_INTEROP=/run/WSL/8_interop, WSL_DISTRO_NAME=Ubuntu-20.04, HOSTTYPE=x86_64, JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre, OLDPWD=/root, TERM=xterm-256color, MOTD_SHOWN=update-motd, USER=root, LANG=C.UTF
-8, NAME=GZYZFA00088591, WT_PROFILE_ID={07b52e3e-de2c-5db4-bd2d-ba144ed6c273}, WSLENV=WT_SESSION::WT_PROFILE_ID, LOGNAME=root, LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=4
0;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31
:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;3
1:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.es
d=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.sv
gz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=
01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.
flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:, PWD=/root/rocketmq, SHLVL=1, HOME=/roo
t, _=/root/maven-mvnd-0.8.2-linux-amd64/bin/mvnd}'}
17:49:18.862 I Executing request
17:49:18.920 I Dispatch message: BuildLogMessage{payload='[INFO] Error stacktraces are turned on.'}
17:49:18.922 I Dispatch message: BuildLogMessage{payload='[INFO] Processing build on daemon ca6d1908'}
17:49:18.935 I Dispatch message: BuildLogMessage{payload='[INFO] Scanning for projects...'}
17:49:18.962 E Error while building project
java.lang.Error: java.io.IOException: No such file or directory
        at sun.nio.ch.FileKey.create(FileKey.java:46)
        at sun.nio.ch.SharedFileLockTable.<init>(FileLockTable.java:120)
        at sun.nio.ch.FileLockTable.newSharedFileLockTable(FileLockTable.java:47)
        at sun.nio.ch.FileChannelImpl.fileLockTable(FileChannelImpl.java:1039)
        at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1106)
        at org.eclipse.aether.named.support.FileLockNamedLock.obtainFileLock(FileLockNamedLock.java:273)
        at org.eclipse.aether.named.support.FileLockNamedLock.doLockExclusively(FileLockNamedLock.java:206)
        at org.eclipse.aether.named.support.Retry.retry(Retry.java:69)
        at org.eclipse.aether.named.support.FileLockNamedLock.lockExclusively(FileLockNamedLock.java:100)
        at org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapter$AdaptedLockSyncContext.acquire(NamedLockFactoryAdapter.java:154)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:233)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:212)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:272)
        at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:192)
        at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:242)
        at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:1150)
        at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:916)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:361)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:267)
        at org.apache.maven.project.CachingProjectBuilder.build(CachingProjectBuilder.java:404)
        at org.apache.maven.project.CachingProjectBuilder.build(CachingProjectBuilder.java:373)
        at org.apache.maven.project.CachingProjectBuilder.build(CachingProjectBuilder.java:343)
        at org.apache.maven.graph.DefaultGraphBuilder.collectProjects(DefaultGraphBuilder.java:414)
        at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor(DefaultGraphBuilder.java:405)
        at org.apache.maven.graph.DefaultGraphBuilder.build(DefaultGraphBuilder.java:82)
        at org.apache.maven.DefaultMaven.buildGraph(DefaultMaven.java:532)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:219)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.DaemonMavenCli.execute(DaemonMavenCli.java:687)
        at org.apache.maven.cli.DaemonMavenCli.doMain(DaemonMavenCli.java:239)
        at org.apache.maven.cli.DaemonMavenCli.main(DaemonMavenCli.java:215)
        at org.mvndaemon.mvnd.daemon.Server.handle(Server.java:572)
        at org.mvndaemon.mvnd.daemon.Server.client(Server.java:256)
        at org.mvndaemon.mvnd.daemon.Server.accept(Server.java:224)
        at java.lang.Thread.run(Thread.java:750)
Caused by: java.io.IOException: No such file or directory
        at sun.nio.ch.FileKey.init(Native Method)
        at sun.nio.ch.FileKey.create(FileKey.java:44)
        ... 35 common frames omitted
17:49:18.962 I Dispatch message: BuildException{message='java.io.IOException: No such file or directory', className='java.lang.Error', stackTrace='java.lang.Error: java.io.IOException: No such file or director
y
        at sun.nio.ch.FileKey.create(FileKey.java:46)
        at sun.nio.ch.SharedFileLockTable.<init>(FileLockTable.java:120)
        at sun.nio.ch.FileLockTable.newSharedFileLockTable(FileLockTable.java:47)
        at sun.nio.ch.FileChannelImpl.fileLockTable(FileChannelImpl.java:1039)
        at sun.nio.ch.FileChannelImpl.tryLock(FileChannelImpl.java:1106)
        at org.eclipse.aether.named.support.FileLockNamedLock.obtainFileLock(FileLockNamedLock.java:273)
        at org.eclipse.aether.named.support.FileLockNamedLock.doLockExclusively(FileLockNamedLock.java:206)
        at org.eclipse.aether.named.support.Retry.retry(Retry.java:69)
        at org.eclipse.aether.named.support.FileLockNamedLock.lockExclusively(FileLockNamedLock.java:100)
        at org.eclipse.aether.internal.impl.synccontext.named.NamedLockFactoryAdapter$AdaptedLockSyncContext.acquire(NamedLockFactoryAdapter.java:154)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts(DefaultArtifactResolver.java:233)
        at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact(DefaultArtifactResolver.java:212)
        at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact(DefaultRepositorySystem.java:272)
        at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:192)
        at org.apache.maven.project.ProjectModelResolver.resolveModel(ProjectModelResolver.java:242)
        at org.apache.maven.model.building.DefaultModelBuilder.readParentExternally(DefaultModelBuilder.java:1150)
        at org.apache.maven.model.building.DefaultModelBuilder.readParent(DefaultModelBuilder.java:916)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:361)
        at org.apache.maven.model.building.DefaultModelBuilder.build(DefaultModelBuilder.java:267)
        at org.apache.maven.project.CachingProjectBuilder.build(CachingProjectBuilder.java:404)
        at org.apache.maven.project.CachingProjectBuilder.build(CachingProjectBuilder.java:373)
        at org.apache.maven.project.CachingProjectBuilder.build(CachingProjectBuilder.java:343)
        at org.apache.maven.graph.DefaultGraphBuilder.collectProjects(DefaultGraphBuilder.java:414)
        at org.apache.maven.graph.DefaultGraphBuilder.getProjectsForMavenReactor(DefaultGraphBuilder.java:405)
        at org.apache.maven.graph.DefaultGraphBuilder.build(DefaultGraphBuilder.java:82)
        at org.apache.maven.DefaultMaven.buildGraph(DefaultMaven.java:532)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:219)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.DaemonMavenCli.execute(DaemonMavenCli.java:687)
        at org.apache.maven.cli.DaemonMavenCli.doMain(DaemonMavenCli.java:239)
        at org.apache.maven.cli.DaemonMavenCli.main(DaemonMavenCli.java:215)
        at org.mvndaemon.mvnd.daemon.Server.handle(Server.java:572)
        at org.mvndaemon.mvnd.daemon.Server.client(Server.java:256)
        at org.mvndaemon.mvnd.daemon.Server.accept(Server.java:224)
        at java.lang.Thread.run(Thread.java:750)
Caused by: java.io.IOException: No such file or directory
        at sun.nio.ch.FileKey.init(Native Method)
        at sun.nio.ch.FileKey.create(FileKey.java:44)
        ... 35 more
'}
17:49:18.963 I No more message to dispatch
17:49:18.963 I Daemon back to idle
17:49:18.963 I Updating state to: Idle
17:49:18.963 D daemon is running. Sleeping until state changes.
17:49:28.821 D Expiration check running
17:49:38.821 D Expiration check running
17:49:48.821 D Expiration check running
17:49:58.821 D Expiration check running
17:50:08.821 D Expiration check running
17:50:18.821 D Expiration check running
17:50:28.821 D Expiration check running
17:50:38.821 D Expiration check running
17:50:48.821 D Expiration check running
17:50:58.821 D Expiration check running
17:51:08.821 D Expiration check running
17:51:18.821 D Expiration check running
17:51:28.821 D Expiration check running
17:51:38.821 D Expiration check running

@gnodet
Copy link
Contributor

gnodet commented Mar 13, 2023

This is a maven resolver bug. It seems similar to takari/takari-local-repository#6
@cstamas ?

@cstamas
Copy link
Member

cstamas commented Mar 14, 2023

FYI microsoft/WSL#5762

@cstamas
Copy link
Member

cstamas commented Mar 14, 2023

In short, WSL2 "sells" itself as Linux, but LockFileEx is not supported. This will not work until fixed by WSL2. User could experiment by some other locking solutions like Redis backed one https://maven.apache.org/resolver/maven-resolver-named-locks-redisson/index.html

Or, just as experiment, do this:

  • make sure are daemons are shut down
  • invoke ONE build (to make sure ONE daemon runs) with this -Daether.syncContext.named.factory=rwlock-local

This would make mvnd use "jvm local" locking (not multi process capable), but would at least show is there any other issue on WSL2.

@cstamas
Copy link
Member

cstamas commented Mar 14, 2023

This is a maven resolver bug. It seems similar to takari/takari-local-repository#6 @cstamas ?

Takari "shared repository" is unrelated to resolver named locks, and did suffer for bug never fixed, is not related in any way.

@gnodet gnodet changed the title [Need Help]Encounter a problem when i am used mvnd to build project File lock problems when running under WSL Mar 14, 2023
@gnodet
Copy link
Contributor

gnodet commented Mar 14, 2023

Resurrecting the previous IPC SyncContext could be an idea, see https://issues.apache.org/jira/browse/MRESOLVER-342
As a short term improvement, we could also detect and log a WARNING, as mvnd uses the file lock by default.

@michael-o
Copy link
Member

michael-o commented Mar 14, 2023

To whom it may concern: According to my findings, the file-lock named lock factory in Resolver is broken. See: https://issues.apache.org/jira/browse/MNG-7705

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants