GitHub user laimis opened a pull request:

    https://github.com/apache/lucenenet/pull/135

    Fix "The process cannot access the file '...' because it is being used by 
another process." issues

    A good number of tests fail with the error message stating that certain 
file cannot be accessed. Side by side comparison with what Lucene is doing 
while using Filemon showed that Lucene.Net version was opening the filestreams 
with correct FileAccess flag but incorrect FileShare flag. Instead of read it 
should have been ReadWrite.
    
    The failure would occur when writer was disposed and it called IOUtils 
fsync. Fsync opens the stream again in FileAccess ReadWrite mode while at the 
same time there were readers that have the file opened with FileShare set to 
Read only.
    
    Here is the screenshot of the file handle opened when Lucene is running:
    
    
![javaversion](https://cloud.githubusercontent.com/assets/911757/7439229/af717934-f041-11e4-84a6-42dd073eab08.PNG)
    
    And here is the Lucene.Net:
    
    
![dotnetversion](https://cloud.githubusercontent.com/assets/911757/7439236/c787fca0-f041-11e4-8453-040200d2ca0f.PNG)
    
    (hopefully these images come through).
    
    Also was using the TestBufferedIndexInput to confirm the fix and noticed 
that it was rewritten to use using(..)s but during the rewrite some code was 
omitted so I rewrote it back to match exactly what Lucene is doing so it is 
easier to compare.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/laimis/lucenenet filesharingfix

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/lucenenet/pull/135.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #135
    
----
commit 19f506cd6a2fe4c84f4b1df2d51e48e24757c11c
Author: Laimonas Simutis <[email protected]>
Date:   2015-05-02T00:28:28Z

    open with read/write sharing instead of read

commit ff6f2426cb96a74f5573350ee0e1b56bcc9dbcd9
Author: Laimonas Simutis <[email protected]>
Date:   2015-05-02T00:30:59Z

    put back the test to match what Lucene is doing

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to