mirror of https://github.com/apache/lucene.git
LUCENE-7302: IW.getMaxCompletedSequenceNumber was returning the wrong value after IW.deleteAll
This commit is contained in:
parent
6c730ab74f
commit
4ff882e4aa
|
@ -148,6 +148,10 @@ final class DocumentsWriter implements Closeable, Accountable {
|
||||||
return seqNo;
|
return seqNo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synchronized void setLastSeqNo(long seqNo) {
|
||||||
|
lastSeqNo = seqNo;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: we could check w/ FreqProxTermsWriter: if the
|
// TODO: we could check w/ FreqProxTermsWriter: if the
|
||||||
// term doesn't exist, don't bother buffering into the
|
// term doesn't exist, don't bother buffering into the
|
||||||
// per-DWPT map (but still must go into the global map)
|
// per-DWPT map (but still must go into the global map)
|
||||||
|
|
|
@ -765,8 +765,7 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* <b>NOTE:</b> after ths writer is created, the given configuration instance
|
* <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
|
* cannot be passed to another writer.
|
||||||
* {@link IndexWriterConfig#clone() clone} it beforehand.
|
|
||||||
*
|
*
|
||||||
* @param d
|
* @param d
|
||||||
* the index directory. The index is either created or appended
|
* the index directory. The index is either created or appended
|
||||||
|
@ -2348,7 +2347,9 @@ public class IndexWriter implements Closeable, TwoPhaseCommit, Accountable {
|
||||||
globalFieldNumberMap.clear();
|
globalFieldNumberMap.clear();
|
||||||
|
|
||||||
success = true;
|
success = true;
|
||||||
return docWriter.deleteQueue.getNextSequenceNumber();
|
long seqNo = docWriter.deleteQueue.getNextSequenceNumber();
|
||||||
|
docWriter.setLastSeqNo(seqNo);
|
||||||
|
return seqNo;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
docWriter.unlockAllAfterAbortAll(this);
|
docWriter.unlockAllAfterAbortAll(this);
|
||||||
|
|
|
@ -534,4 +534,19 @@ public class TestControlledRealTimeReopenThread extends ThreadedIndexingAndSearc
|
||||||
iw.close();
|
iw.close();
|
||||||
dir.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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue