MMapDirectory on Windows silently fails to write to a file if also open for read --------------------------------------------------------------------------------
Key: LUCENE-1669 URL: https://issues.apache.org/jira/browse/LUCENE-1669 Project: Lucene - Java Issue Type: Bug Components: Store Reporter: Michael McCandless Priority: Minor This is not a normal situation Lucene currently encounters, though we are discussing exactly this possibility in LUCENE-1313. I only hit it in digging down on a test failure in LUCENE-1658: {code} [junit] Testcase: testIndexAndMerge(org.apache.lucene.index.TestDoc): FAILED [junit] junit.framework.AssertionFailedError: [junit] at org.apache.lucene.index.FieldsWriter.addRawDocuments(FieldsWriter.java:249) [junit] at org.apache.lucene.index.SegmentMerger.mergeFields(SegmentMerger.java:350) [junit] at org.apache.lucene.index.SegmentMerger.merge(SegmentMerger.java:139) [junit] at org.apache.lucene.index.SegmentMerger.merge(SegmentMerger.java:116) [junit] at org.apache.lucene.index.TestDoc.merge(TestDoc.java:182) [junit] at org.apache.lucene.index.TestDoc.testIndexAndMerge(TestDoc.java:117) [junit] at org.apache.lucene.util.LuceneTestCase.runTest(LuceneTestCase.java:88) {code} That failure happens on Windows 64bit, if you use MMapDirectory, and the index is on a remote (CIFS) mount. This test opens a SegmentReader against doc store files that IndexWriter still has open. I whittled it down to this test showing the root cause: {code} public void testMMapWriteRead() throws Exception { MMapDirectory dir = new MMapDirectory(new File("readwrite"), null); //NIOFSDirectory dir = new NIOFSDirectory(new File("readwrite"), null); //SimpleFSDirectory dir = new SimpleFSDirectory(new File("readwrite"), null); IndexOutput out = dir.createOutput("one"); out.writeLong(17); out.flush(); // open the same file we are writing dir.openInput("one").close(); // write another long out.writeLong(56); out.close(); IndexInput in = dir.openInput("one"); assertEquals(17, in.readLong()); assertEquals(56, in.readLong()); in.close(); } {code} NIOFSDir and SimpleFSDir pass the test fine, which is nice to know (for LUCENE-1313). MMapDir passes fine on a local drive, but fails on a remote CIFS mount. I'm not sure what's going on. It seems like it could be a JRE bug -- behavior shouldn't change on local vs remote drive. I've only tested it with java 1.6.0_11. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscr...@lucene.apache.org For additional commands, e-mail: java-dev-h...@lucene.apache.org