LUCENE-9504 Remove extra lock in DocumentsWriterDeleteQueue (#1826)

This commit is contained in:
Mike Drob 2020-09-08 10:13:18 -05:00 committed by GitHub
parent b988d557d7
commit 4c5c8c4ead
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 14 deletions

View File

@ -509,27 +509,18 @@ final class DocumentsWriterDeleteQueue implements Accountable, Closeable {
}
}
private boolean forceApplyGlobalSlice() {
globalBufferLock.lock();
final Node<?> currentTail = tail;
public int getBufferedUpdatesTermsSize() {
final ReentrantLock lock = globalBufferLock; // Trusted final
lock.lock();
try {
final Node<?> currentTail = tail;
if (globalSlice.sliceTail != currentTail) {
globalSlice.sliceTail = currentTail;
globalSlice.apply(globalBufferedUpdates, BufferedUpdates.MAX_INT);
}
return globalBufferedUpdates.any();
} finally {
globalBufferLock.unlock();
}
}
public int getBufferedUpdatesTermsSize() {
globalBufferLock.lock();
try {
forceApplyGlobalSlice();
return globalBufferedUpdates.deleteTerms.size();
} finally {
globalBufferLock.unlock();
lock.unlock();
}
}