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

Updated domain.xml file management + CI for windows #25205

Merged
merged 10 commits into from
Nov 6, 2024

Conversation

dmatej
Copy link
Contributor

@dmatej dmatej commented Nov 2, 2024

Story

I am using a backup laptop now, and to my surprise some tests started failing. File locking tests here fail just like on Arjan's Mac last year, but I am on Kubuntu 24.10, fs ext4. On Kubuntu 24.04 with ext4 they always passed, same on Jenkins CI, so it seems it might be something around CPU, OS, or NVME firmware, I have no idea.

I had doubts if this removal of ManagedFile would not break something on Windows, so I decided to add windows-based CI build to check as I don't have any Windows machine available at this moment.

Changes

  • New GitHub Action for all pull requests - build on Windows.

  • Original impl of locking: when something threw an exception, it continued without this locking.

  • It used different file for locking, because domain.xml was renamed, deleted.

  • Two test classes failed on some systems - Arjan's Mac, David's Ubuntu HP, but passed on Jenkins CI and David's Ubuntu Dell. Differences were also on other systems. We have never found exact reason why.

  • Basically I believe that any implementation will be unreliable, because we do access domain.xml file from different processes, move it, write and read it and the access cannot use any kind of locking except native hard drive and whatever is provided by the system. But once we delete the file, we lose its handle in JVM and all locks are gone. The order of operations is unspecified, we can control just our own work with the given path.

  • Fixed or disabled tests which failed on Windows.

    • SQLTraceListenerTest was not able to remove the temporary directory. There was a mistake - classloader used the source file, not its own copy.
    • configFileUri wasn't always an URI, sometimes it was just absolute path. Windows paths cannot be directly used to create an URI. See also similar issue in Java: https://bugs.openjdk.org/browse/JDK-8218268
    • StartServITest.reportCorrectErrorIfAlreadyRunning was disabled on windows because the bat file is not so well implemented like it is for Linux, it is just trivial.

- When something threw an exception, it continued without this locking.
- It used different file for locking, because domain.xml was renamed, deleted.
- Two test classes failed on some systems - Arjan's Mac, David's Ubuntu HP, but
  passed on CI and David's Ubuntu Dell. Differences were also on other systems.
  We have never found exact reason why.
- Basically I believe that any implementation will be unreliable, because we
  do access domain.xml file from different processes, move it, write and read
  it and the access cannot use any kind of locking except native hard drive and
  whatever is provided by the system. But once we delete the file, we lose its
  handle in JVM and all locks are gone. The order of operations is unspecified,
  we can control just our own work with the given path.
- So ... here I use just the read lock which should protect the file when some
  thread is reading it. File manipulation uses NIO.
- Is it everything ...?

Signed-off-by: David Matějček <[email protected]>
@dmatej dmatej added this to the 7.0.20 milestone Nov 2, 2024
@dmatej dmatej self-assigned this Nov 2, 2024
- Now throws exceptions when something goes wrong
- Doesn't ignore failed renames
- AddLibraryCommand uses result of this method for the classloader

Signed-off-by: David Matějček <[email protected]>
@dmatej dmatej changed the title Removed old ManagedFile locking of domain.xml Updated domain.xml file management + CI for windows Nov 3, 2024
- Were missing on some places
- That fact broke some tests on some Windows file systems which used
  "suspicious" file path/uri strings refused by java while the string should
  have always been an URI.
- I pushed the conversion from getters to setters to make it clear what kind of
  URI/path was used - then we can do more appropriate coversion earlier and just
  once (however GlassFishProperties are still just a bunch of strings so
  there will still be redundant conversions for now).

Signed-off-by: David Matějček <[email protected]>
- If we would experience some issues with race conditions over domain.xml,
  we have to find better solution, because this did not pass its own tests
  on some file systems (my HP Victus with Kubuntu 24.10 and ext4, virtual
  Windows Server 2022 provided by GitHub Actions, maybe other).

Signed-off-by: David Matějček <[email protected]>
@dmatej dmatej merged commit c354344 into eclipse-ee4j:master Nov 6, 2024
3 checks passed
@dmatej dmatej deleted the filelocking branch November 6, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants