Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
-
New
Description
This build:
https://builds.apache.org/job/Lucene-Solr-NightlyTests-master/1761/consoleText
failed with the following stack trace:
FAILED: org.apache.lucene.util.TestOfflineSorter.testThreadSafety Error Message: Captured an uncaught exception in thread: Thread[id=2665, name=Thread-2493, state=RUNNABLE, group=TGRP-TestOfflineSorter] Stack Trace: com.carrotsearch.randomizedtesting.UncaughtExceptionError: Captured an uncaught exception in thread: Thread[id=2665, name=Thread-2493, state=RUNNABLE, group=TGRP-TestOfflineSorter] Caused by: java.lang.RuntimeException: java.nio.file.AccessDeniedException: Can't open a file still open for writing: unsorted_tmp_0.tmp at __randomizedtesting.SeedInfo.seed([972EEC94E272C842]:0) at org.apache.lucene.util.TestOfflineSorter$2.run(TestOfflineSorter.java:271) Caused by: java.nio.file.AccessDeniedException: Can't open a file still open for writing: unsorted_tmp_0.tmp at org.apache.lucene.store.ByteBuffersDirectory$FileEntry.openInput(ByteBuffersDirectory.java:250) at org.apache.lucene.store.ByteBuffersDirectory.openInput(ByteBuffersDirectory.java:222) at org.apache.lucene.store.NRTCachingDirectory.slowFileExists(NRTCachingDirectory.java:292) at org.apache.lucene.store.NRTCachingDirectory.createTempOutput(NRTCachingDirectory.java:266) at org.apache.lucene.store.MockDirectoryWrapper.createTempOutput(MockDirectoryWrapper.java:697) at org.apache.lucene.util.TestOfflineSorter.checkSort(TestOfflineSorter.java:183) at org.apache.lucene.util.TestOfflineSorter.access$100(TestOfflineSorter.java:49) at org.apache.lucene.util.TestOfflineSorter$2.run(TestOfflineSorter.java:267)
The problem in slowFileExists is that it probes for file existence by trying to open it in a directory. We don't allow opening files that are still open by another thread (for writing), hence the exception thrown is AccessDeniedException.
I couldn't reproduce the problem with the same seed. Takes some luck to hit the right scenario in a multi-threaded run.
The contract for Directory.fileLength is less strict so a straightforward patch is to use that instead.