Skip to content

Conversation

@uschindler
Copy link
Contributor

@uschindler uschindler commented May 8, 2025

Windows does not support file keys (the attribute returns null which is documented by OpenJDK that it is optional). Therefore WindowsFS cannot be used on Windows.

Due to Windows 11 no longer preventing deletion of open files, we need to be able to use WindowsFS on Windows (irony), fix this to fallback to realpath as key. It should be good enough like an inode. Renaming/moving files is already handled by WindowsFS when it detects a change in key after rename/move.

Closes #11920

…efor WindowsFS cannot be used on Windows. Due to Windows 11 no longer preventing depleting of open files, we need to be able to use WindowsFS on Windows (irony), fix this to fallback to realpath as key. It should be good enough like an inode. Renaming/moving files is already handles by WindowsFS when it detects a change in key after rename/move.

Closes apache#11920
@uschindler
Copy link
Contributor Author

Looks like it also passes with Windows 10 / Windows server 2022 (as used by Github).

Copy link
Member

@rmuir rmuir left a comment

Choose a reason for hiding this comment

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

Seems fine: thanks for fixing this.

@uschindler
Copy link
Contributor Author

@rmuir : It also works with the path (without realpath). Maybe we can just fallback to the path instead of realpath. It should be good enough, too and reduces overhead.

What do you think?

}
// the key may be null, e.g. on real Windows!
// in that case we fallback to the real path
return existing.toRealPath();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

it also works with plain path. as we do not use symlinks on windows the extra toRealPath() seems to be useless overhead.

Copy link
Contributor Author

@uschindler uschindler May 8, 2025

Choose a reason for hiding this comment

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

@rmuir : You added thumbs up. Should I remove the realPath or leave it in? I feel better with realPath, but it may slowdown even more.

Copy link
Member

Choose a reason for hiding this comment

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

We don't need to test for theoretical situations such as symlinks when we dont use them in lucene? So I would go with the fastest/simplest route, that solves our needs.

Its not a generic windows filesystem simulator, just good enough for our needs, to prevent deleting open files and test the logic surrounding that.

Copy link
Member

Choose a reason for hiding this comment

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

and maybe the fileKey should have just never been used all along. There is a hardlinks functionality on linux, which was maybe why I tried to use inode...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. I will change to plain path and only use filekey if it is available.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in b4c66ea

Copy link
Contributor Author

@uschindler uschindler May 8, 2025

Choose a reason for hiding this comment

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

and maybe the fileKey should have just never been used all along. There is a hardlinks functionality on linux, which was maybe why I tried to use inode...

Yes for hardlinks (we use them for addIndexes) it might be useful. So I made it to just fallback to the path if no fileKey is available. So we have best on both worlds. On Windows, here there are no hardlinks (or links at all without being root) the fallback to path solves all issues.

To me it was important: If WindowsFS is used on Posix, we won't cause unwanted failures.

@uschindler
Copy link
Contributor Author

uschindler commented May 8, 2025

I was able to remove the assume on more tests.

Basically we should possibly also automatically enable WindowsFS randomly for Windows, too. This would allow to test legacy Windows behaviour also on Windows 11. Will add a followup commit once Github runner is happy.

Copy link
Contributor

@dweiss dweiss left a comment

Choose a reason for hiding this comment

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

thanks, uwe.

@uschindler
Copy link
Contributor Author

Hi,
it looks like all works well with Windows and WindowsFS.

For now I left the toReal() path in the key generation. I am still unsure if it won't be enough to use the plain path as key. On Windows we won't have symlinks.... And if the directory itsself is a symlink we can ignore that because it is not relevant to the test.

@uschindler
Copy link
Contributor Author

It also works on my local Windows 11 machine.

@uschindler
Copy link
Contributor Author

I'll will merge this after the tests pass here. Let's see how it behaves long term.

@uschindler
Copy link
Contributor Author

Theres one small problem that makes one test fail. ACtually the backslash is a reserved character (if used in Unix), but on Windows, it is actually the file separator.

I will add a workaround, so on windows it allows backslash.

@uschindler uschindler merged commit ccc8f7e into apache:main May 8, 2025
7 checks passed
@uschindler uschindler deleted the dev/fix11920 branch May 8, 2025 12:29
@uschindler
Copy link
Contributor Author

I am out for lunch and only have my smartphone so can't cherry 🍒 pick to stable branch. Will do this when back at home, unless somebody wants to step in to silence Jenkins.

mikemccand pushed a commit that referenced this pull request May 8, 2025
Windows does not support file keys (the attribute returns null). Therefor WindowsFS cannot be used on Windows. Due to Windows 11 no longer preventing depleting of open files, we need to be able to use WindowsFS on Windows (irony), fix this to fallback to path as key. It should be good enough like an inode. Renaming/moving files is already handles by WindowsFS when it detects a change in key after rename/move.

Closes #11920
@mikemccand
Copy link
Member

I am out for lunch and only have my smartphone so can't cherry 🍒 pick to stable branch. Will do this when back at home, unless somebody wants to step in to silence Jenkins.

I cherry-picked 67fdb91 @uschindler! Enjoy your lunch!

jainankitk pushed a commit that referenced this pull request Sep 23, 2025
Windows does not support file keys (the attribute returns null). Therefor WindowsFS cannot be used on Windows. Due to Windows 11 no longer preventing depleting of open files, we need to be able to use WindowsFS on Windows (irony), fix this to fallback to path as key. It should be good enough like an inode. Renaming/moving files is already handles by WindowsFS when it detects a change in key after rename/move.

Closes #11920
@jainankitk jainankitk modified the milestones: 10.3.0, 9.12.3 Sep 28, 2025
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.

Test testDeleteUnusedFiles() failed in TestIndexWriter

5 participants