s1monw commented on a change in pull request #1427: LUCENE-9304: Fix IW#getMaxCompletedSequenceNumber() URL: https://github.com/apache/lucene-solr/pull/1427#discussion_r407987965
########## File path: lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java ########## @@ -3949,4 +3950,69 @@ public void testRandomOperationsWithSoftDeletes() throws Exception { } } } + + public void testMaxCompletedSequenceNumber() throws IOException, InterruptedException { + try (Directory dir = newDirectory(); + IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig());) { + assertEquals(1, writer.addDocument(new Document())); + assertEquals(2, writer.updateDocument(new Term("foo", "bar"), new Document())); + writer.flushNextBuffer(); + assertEquals(3, writer.commit()); + assertEquals(4, writer.addDocument(new Document())); + assertEquals(4, writer.getMaxCompletedSequenceNumber()); + // commit moves seqNo by 2 since there is one DWPT that could still be in-flight + assertEquals(6, writer.commit()); + assertEquals(6, writer.getMaxCompletedSequenceNumber()); + assertEquals(7, writer.addDocument(new Document())); + writer.getReader().close(); + // getReader moves seqNo by 2 since there is one DWPT that could still be in-flight + assertEquals(9, writer.getMaxCompletedSequenceNumber()); + } + try (Directory dir = newDirectory(); Review comment: I added a very specific testcase that fails always. good call on pushing for a better test! ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org