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

Sporadic failures with -w/--watch #2808

Closed
lihaoyi opened this issue Oct 2, 2023 · 2 comments · Fixed by #2832
Closed

Sporadic failures with -w/--watch #2808

lihaoyi opened this issue Oct 2, 2023 · 2 comments · Fixed by #2832
Labels
bug The issue represents an bug
Milestone

Comments

@lihaoyi
Copy link
Member

lihaoyi commented Oct 2, 2023

Started seeing this when working on a new project. Pretty trivial single-module Scala build. Mill 0.11.x. Not sure why I've never seen it before elsewhere, but it seems pretty frequent (happens several times a day). Using Intellij BSP.

Not sure what the ~ is at the end of /Users/lihaoyi/Github/usql/test/src/MainTests.scala~. Maybe some kind of temporary file IntelliJ/IntelliJ-BSP is creating and deleting quickly, cause a TOCTTOU race condition?

Watching for changes to 11 paths and 4 other values... (Enter to re-run, Ctrl-C to exit)
Exception in thread "main" java.lang.reflect.InvocationTargetException
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at mill.main.client.IsolatedMillMainLoader.runMain(IsolatedMillMainLoader.java:58)
	at mill.main.client.MillClientMain.main(MillClientMain.java:64)
Caused by: java.nio.file.NoSuchFileException: /Users/lihaoyi/Github/usql/test/src/MainTests.scala~
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:92)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:111)
	at java.base/sun.nio.fs.UnixFileAttributeViews$Posix.readAttributes(UnixFileAttributeViews.java:257)
	at java.base/sun.nio.fs.UnixFileAttributeViews$Posix.readAttributes(UnixFileAttributeViews.java:168)
	at java.base/sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:148)
	at java.base/java.nio.file.Files.readAttributes(Files.java:1851)
	at java.base/java.nio.file.Files.getPosixFilePermissions(Files.java:2125)
	at os.perms$.apply(PermsOps.scala:13)
	at mill.api.PathRef$.$anonfun$apply$3(PathRef.scala:131)
	at mill.api.PathRef$.$anonfun$apply$3$adapted(PathRef.scala:124)
	at scala.collection.IterableOnceOps.foreach(IterableOnce.scala:576)
	at scala.collection.IterableOnceOps.foreach$(IterableOnce.scala:574)
	at scala.collection.AbstractIterable.foreach(Iterable.scala:933)
	at scala.collection.IterableOps$WithFilter.foreach(Iterable.scala:903)
	at mill.api.PathRef$.apply(PathRef.scala:124)
	at mill.api.PathRef.recomputeSig(PathRef.scala:23)
	at mill.util.Watchable$Path.poll(Watchable.scala:21)
	at mill.util.Watchable.validate(Watchable.scala:15)
	at mill.util.Watchable.validate$(Watchable.scala:15)
	at mill.util.Watchable$Path.validate(Watchable.scala:20)
	at mill.runner.Watching$.$anonfun$statWatchWait$1(Watching.scala:75)
	at mill.runner.Watching$.$anonfun$statWatchWait$1$adapted(Watching.scala:75)
	at scala.collection.immutable.List.forall(List.scala:386)
	at mill.runner.Watching$.statWatchWait0$1(Watching.scala:75)
	at mill.runner.Watching$.statWatchWait(Watching.scala:98)
	at mill.runner.Watching$.watchAndWait(Watching.scala:67)
	at mill.runner.Watching$.watchLoop(Watching.scala:45)
	at mill.runner.MillMain$.$anonfun$main0$1(MillMain.scala:198)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
	at scala.Console$.withErr(Console.scala:193)
	at mill.api.SystemStreams$.$anonfun$withStreams$2(SystemStreams.scala:62)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
	at scala.Console$.withOut(Console.scala:164)
	at mill.api.SystemStreams$.$anonfun$withStreams$1(SystemStreams.scala:61)
	at scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
	at scala.Console$.withIn(Console.scala:227)
	at mill.api.SystemStreams$.withStreams(SystemStreams.scala:60)
	at mill.runner.MillMain$.main0(MillMain.scala:80)
	at mill.runner.MillMain$.main(MillMain.scala:58)
	at mill.runner.MillMain.main(MillMain.scala)
	... 6 more
@lefou
Copy link
Member

lefou commented Oct 2, 2023

If it's some temporary file, we should ignore it when collecting source files. We already apply a filter to exclude linux hidden files starting with a dot.

@lihaoyi
Copy link
Member Author

lihaoyi commented Oct 8, 2023

Ignoring specific files won't help, because the crash comes when checking the PathRef signature for the entire src/ folder, before we have chance to filter individual files

We could add some smartness to PathRef to provide some way of pre-filtering things, but for now we should just make it robust and fail a bit more elegantly in the face of concurrent updates

lihaoyi added a commit that referenced this issue Oct 9, 2023
…ons (#2832)

Attempts to fix #2808

No real tests; the failure is timing-dependent and hard to reproduce.
But hopefully just wrapping everything up in a big try-catch will fix it

Pull request: #2832
@lefou lefou added this to the 0.11.6 milestone Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug The issue represents an bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants