Permalink
Browse files

LUCENE-7302: IW.getMaxCompletedSequenceNumber was returning the wrong…

… value after IW.deleteAll
  • Loading branch information...
mikemccand committed Jul 6, 2016
1 parent bc502bd commit 503da1fcb9fa96c2ba62e9164ee38011b2e23669
@@ -148,6 +148,10 @@ synchronized long deleteQueries(final Query... queries) throws IOException {
return seqNo;
}
synchronized void setLastSeqNo(long seqNo) {
lastSeqNo = seqNo;
}
// TODO: we could check w/ FreqProxTermsWriter: if the
// term doesn't exist, don't bother buffering into the
// per-DWPT map (but still must go into the global map)
@@ -765,8 +765,7 @@ protected final void ensureOpen() throws AlreadyClosedException {
*
* <p>
* <b>NOTE:</b> after ths writer is created, the given configuration instance
* cannot be passed to another writer. If you intend to do so, you should
* {@link IndexWriterConfig#clone() clone} it beforehand.
* cannot be passed to another writer.
*
* @param d
* the index directory. The index is either created or appended
@@ -2348,7 +2347,9 @@ public long deleteAll() throws IOException {
globalFieldNumberMap.clear();
success = true;
return docWriter.deleteQueue.getNextSequenceNumber();
long seqNo = docWriter.deleteQueue.getNextSequenceNumber();
docWriter.setLastSeqNo(seqNo);
return seqNo;
} finally {
docWriter.unlockAllAfterAbortAll(this);
@@ -534,4 +534,19 @@ public void run() {
iw.close();
dir.close();
}
public void testDeleteAll() throws Exception {
Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, newIndexWriterConfig());
SearcherManager mgr = new SearcherManager(w, new SearcherFactory());
nrtDeletesThread = new ControlledRealTimeReopenThread<>(w, mgr, 0.1, 0.01);
nrtDeletesThread.setName("NRTDeletes Reopen Thread");
nrtDeletesThread.setDaemon(true);
nrtDeletesThread.start();
long gen1 = w.addDocument(new Document());
long gen2 = w.deleteAll();
nrtDeletesThread.waitForGeneration(gen2);
IOUtils.close(nrtDeletesThread, nrtDeletes, w, dir);
}
}

0 comments on commit 503da1f

Please sign in to comment.