You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucenenet.apache.org by "paulirwin (via GitHub)" <gi...@apache.org> on 2026/06/12 22:27:10 UTC

[PR] Add FileShare.Delete to SimpleFSDirectory and FSIndexOutput, #1283 [lucenenet]

paulirwin opened a new pull request, #1344:
URL: https://github.com/apache/lucenenet/pull/1344

   - [X] You've read the [Contributor Guide](https://github.com/apache/lucenenet/blob/master/CONTRIBUTING.md) and [Code of Conduct](https://www.apache.org/foundation/policies/conduct.html).
   - [X] You've included unit or integration tests for your change, where applicable.
   - [X] You've included inline docs for your change, where applicable.
   - [X] There's an open issue for the PR that you are making. If you'd like to propose a change, please [open an issue](https://github.com/apache/lucenenet/issues/new/choose) to discuss the change or find an existing issue.
   
   Add FileShare.Delete to SimpleFSDirectory and FSIndexOutput
   
   Fixes #1283
   
   ## Description
   
   SimpleFSDirectory opened its read handles with FileShare.ReadWrite, diverging from NIOFSDirectory (ReadWrite | Delete). On Windows this caused File.Delete to throw a sharing violation while a reader held the file open; IndexFileDeleter swallows that and defers the delete to a retry list, so superseded index files accumulate on disk for the lifetime of a long-lived reader.
   
   Add FileShare.Delete to both SimpleFSDirectory read handles and to the shared FSIndexOutput write handle (used by all FSDirectory subclasses) so that every handle Lucene.NET opens on a file permits deletion. Windows requires all open handles to allow Delete share for a delete to succeed, making the guarantee unconditional and matching the POSIX delete-while-open semantics that IndexFileDeleter already assumes.
   
   This is a deliberate divergence from upstream Java, whose RandomAccessFile (used by SimpleFS for both read and write) omits FILE_SHARE_DELETE on Windows; only FileChannel (NIOFS/MMap) includes it. MMapDirectory's read handle is addressed separately in #1267.
   
   Adds Windows-gated regression tests in TestDirectory that confirm a delete succeeds while a read or write handle is open (and that the still-open read handle keeps returning the original bytes).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Add FileShare.Delete to SimpleFSDirectory and FSIndexOutput, #1283 [lucenenet]

Posted by "paulirwin (via GitHub)" <gi...@apache.org>.
paulirwin merged PR #1344:
URL: https://github.com/apache/lucenenet/pull/1344


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@lucenenet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org