Issue Details (XML | Word | Printable)

Key: LUCENE-665
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Major Major
Assignee: Unassigned
Reporter: Doron Cohen
Votes: 1
Watchers: 4
Operations

If you were logged in you would be able to see more operations.
Lucene - Java

temporary file access denied on Windows

Created: 25/Aug/06 11:21 PM   Updated: 12/Jan/07 05:34 PM
Return to search
Component/s: Store
Affects Version/s: 2.0.0
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
Text File FSDirectory_Retry_Logic.patch 2006-08-25 11:21 PM Doron Cohen 4 kB
Text File Licensed for inclusion in ASF works FSDirs_Retry_Logic_3.patch 2006-08-30 06:24 AM Doron Cohen 8 kB
Text File Licensed for inclusion in ASF works FSWinDirectory.patch 2006-09-20 08:37 AM Doron Cohen 26 kB
Text File Licensed for inclusion in ASF works FSWinDirectory_26_Sep_06.patch 2006-09-27 06:26 AM Doron Cohen 25 kB
Text File Test_Output.txt 2006-08-25 11:21 PM Doron Cohen 3 kB
Java Source File TestInterleavedAddAndRemoves.java 2006-08-25 11:21 PM Doron Cohen 4 kB
Environment: Windows

Resolution Date: 12/Jan/07 05:29 PM


 Description  « Hide
When interleaving adds and removes there is frequent opening/closing of readers and writers.

I tried to measure performance in such a scenario (for issue 565), but the performance test failed - the indexing process crashed consistently with file "access denied" errors - "cannot create a lock file" in "lockFile.createNewFile()" and "cannot rename file".

This is related to:

My test setup is: XP (SP1), JAVA 1.5 - both SUN and IBM SDKs.

I noticed that the problem is more frequent when locks are created on one disk and the index on another. Both are NTFS with Windows indexing service enabled. I suspect this indexing service might be related - keeping files busy for a while, but don't know for sure.

After experimenting with it I conclude that these problems - at least in my scenario - are due to a temporary situation - the FS, or the OS, is temporarily holding references to files or folders, preventing from renaming them, deleting them, or creating new files in certain directories.

So I added to FSDirectory a retry logic in cases the error was related to "Access Denied". This is the same approach brought in http://www.nabble.com/running-a-lucene-indexing-app-as-a-windows-service-on-xp%2C-crashing-tf2053536.html - there, in addition to the retry, gc() is invoked (I did not gc()). This is based on the hope that a access-denied situation would vanish after a small delay, and the retry would succeed.

I modified FSDirectory this way for "Access Denied" errors during creating a new files, renaming a file.

This worked fine for me. The performance test that failed before, now managed to complete. There should be no performance implications due to this modification, because only the cases that would otherwise wrongly fail are now delaying some extra millis and retry.

I am attaching here a patch - FSDirectory_Retry_Logic.patch - that has these changes to FSDirectory.
All "ant test" tests pass with this patch.

Also attaching a test case that demostrates the problem - at least on my machine. There two tests cases in that test file - one that works in system temp (like most Lucene tests) and one that creates the index in a different disk. The latter case can only run if the path ("D:" , "tmp") is valid.

It would be great if people that experienced these problems could try out this patch and comment whether it made any difference for them.

If it turns out useful for others as well, including this patch in the code might help to relieve some of those "frustration" user cases.

A comment on state of proposed patch:

  • It is not a "ready to deploy" code - it has some debug printing, showing the cases that the "retry logic" actually took place.
  • I am not sure if current 30ms is the right delay... why not 50ms? 10ms? This is currently defined by a constant.
  • Should a call to gc() be added? (I think not.)
  • Should the retry be attempted also on "non access-denied" exceptions? (I think not).
  • I feel it is somewhat "woodoo programming", but though I don't like it, it seems to work...

Attached files:
1. TestInterleavedAddAndRemoves.java - the LONG test that fails on XP without the patch and passes with the patch.
2. FSDirectory_Retry_Logic.patch
3. Test_Output.txt- output of the test with the patch, on my XP. Only the createNewFile() case had to be bypassed in this test, but for another program I also saw the renameFile() being bypassed.

  • Doron


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Doron Cohen made changes - 30/Aug/06 06:24 AM
Field Original Value New Value
Attachment FSDirs_Retry_Logic_3.patch [ 12339840 ]
Doron Cohen made changes - 20/Sep/06 08:37 AM
Attachment FSWinDirectory.patch [ 12341188 ]
Doron Cohen made changes - 27/Sep/06 06:26 AM
Attachment FSWinDirectory_26_Sep_06.patch [ 12341771 ]
Doron Cohen made changes - 12/Jan/07 05:29 PM
Resolution Won't Fix [ 2 ]
Status Open [ 1 ] Resolved [ 5 ]
Doron Cohen made changes - 12/Jan/07 05:29 PM
Status Resolved [ 5 ] Closed [ 6 ]