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

Appveyor #160

Closed
wants to merge 4 commits into from
Closed

Appveyor #160

wants to merge 4 commits into from

Conversation

eatkins
Copy link
Contributor

@eatkins eatkins commented May 28, 2018

No description provided.

@eatkins
Copy link
Contributor Author

eatkins commented May 28, 2018

The appveyor build is working for my personal account: https://ci.appveyor.com/project/eatkins/io. Someone with appropriate permissions would have to turn on appveyor for the io project.

@eatkins eatkins mentioned this pull request May 28, 2018
@dwijnand dwijnand requested a review from cunei June 1, 2018 18:34
@dwijnand
Copy link
Member

dwijnand commented Jun 1, 2018

@cunei Could you please review the Milli changes in this PR, please?

dwijnand
dwijnand previously approved these changes Jun 6, 2018
Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to land this change, so LGTM.

else
else if (err == ERROR_SHARING_VIOLATION && attempt < MAX_GET_HANDLE_ATTEMPTS) {
Thread.sleep(1)
getHandle(lpFileName, dwDesiredAccess, dwShareMode, attempt + 1)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ERROR_SHARING_VIOLATION should (in theory) already be fixed by this pull request: #134
That PR was merged in 1.x (on March 7th) but it is not in 1.1.x. The 1.1.x branch is still very much active at this point, so it may be worth backporting it, rather than using workarounds. /cc @dwijnand

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In sbt/sbt#3972 (comment), a user reports that an ERROR_SHARING_VIOLATION still appears in a 1.x snapshot when running under the Windows Subsystem for Linux (with #134 applied); conversely in sbt/sbt#3972 (comment) the patch seems to have resolved the issue.
Access permissions are weird in Windows, and I was unable to reproduce it post-patch. In the context of this pull request, I would start by backporting #134 to 1.1.x, and use the workaround proposed by @eatkins only if that is still a problem in Appveyor afterwards. That would be my suggestion, at least.

@@ -281,12 +290,16 @@ private object WinMilli extends MilliNative[FILETIME] {
null)
if (hFile == INVALID_HANDLE_VALUE) {
val err = GetLastError()
if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND || err == ERROR_ACCESS_DENIED)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. An alternative could be throwing java.nio.file.AccessDeniedException for ERROR_ACCESS_DENIED, but java.io.FileNotFoundException was the usual response before nio, so I'm ok with that. I'd just use a different string for the error message in that case, for clarity, like:

if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
  throw new FileNotFoundException("Not found: " + lpFileName)
else if (err == ERROR_ACCESS_DENIED)
  throw new FileNotFoundException("Access denied: " + lpFileName)
else

@eatkins
Copy link
Contributor Author

eatkins commented Jun 7, 2018

@cunei thanks for the suggestions. I'll incorporate them soon and re-push.

eatkins and others added 4 commits August 1, 2018 17:21
This will enable us to run tests in a windows environment during CI. I
am only running io/test since the formatting and binary compatibility
tests are handled by travis and appveyor do not provide as many build
agents as travis.
In Windows, reading or writing file attributes requires opening
the file via CreateFile(). If only FILE_SHARE_READ is specified
when reading the timestamp, the CreateFile() call will fail
when the file happens to be already open for writing. This
pull request specifies that the file that is being opened has
shared read and write access; the shared delete mode (which also
implies rename) is also allowed, and in case the subsequent
timestamp get/set fails (if the file disappears) the usual
exception-to-zero code path will be taken.

See sbt/sbt#3972
After adding the .appveyor.yml, I found that my builds would typically
fail and usually one of the polling watch service threads died with an
IOException with message "CreateFile() failed with error 5." I tracked
this down to ERROR_ACCESS_DENIED, which seemed weird since any of the
files that were being polled were generated by the test. It turns out
that windows will return ERROR_ACCESS_DENIED when the file was in a
pending delete state.
https://stackoverflow.com/questions/6680491/why-does-windows-return-error-access-denied-when-i-try-to-open-a-delete-pended-f
While this feels slightly wrong, it doesn't seem completely unreasonable
to consider ERROR_ACCESS_DENIED to be like a FileNotFoundException. In
either the deleted or privileged file cases, the file is effectively not
findable.

An alternative would be to throw a different exception and catch that in
getModifiedTimeOrZero.
I was seeing transient failures of this test on windows, which has
significantly slower file access apis than linux and osx.
@eatkins
Copy link
Contributor Author

eatkins commented Aug 2, 2018

I closed this in favor of #173, which is compared against 1.2.x instead of 1.1.x. @cunei was right that my transient failures on appveyor went away so I was able to get rid of the polling commit.

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

Successfully merging this pull request may close these issues.

3 participants