LUCENE-8785: Ensure threadstates are locked before iterating (#664)

Ensure new threadstates are locked before retrieving the
number of active threadstates. This causes assertion errors
and potentially broken field attributes in the IndexWriter when
IndexWriter#deleteAll is called while actively indexing.
This commit is contained in:
Simon Willnauer 2019-05-08 11:19:21 +02:00 committed by GitHub
parent 3fa2d8f1d3
commit e8d88a5b54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -452,7 +452,11 @@ Optimizations
(Toke Eskildsen, Adrien Grand)
======================= Lucene 7.7.1 =======================
(No Changes)
Bug fixes:
* LUCENE-8785: Ensure new threadstates are locked before retrieving the number of active threadstates.
This causes assertion errors and potentially broken field attributes in the IndexWriter when
IndexWriter#deleteAll is called while actively indexing. (Simon Willnauer)
======================= Lucene 7.7.0 =======================

View File

@ -287,8 +287,8 @@ final class DocumentsWriter implements Closeable, Accountable {
};
try {
deleteQueue.clear();
final int limit = perThreadPool.getMaxThreadStates();
perThreadPool.lockNewThreadStates();
final int limit = perThreadPool.getMaxThreadStates();
for (int i = 0; i < limit; i++) {
final ThreadState perThread = perThreadPool.getThreadState(i);
perThread.lock();