Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-9453 Assert lock held before volatile write (#1734)

Mike Drob092076ec39e0
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
index e3df50555a3..5684bf42b0f 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
@@ -324,12 +324,16 @@ final class DocumentsWriterFlushControl implements Accountable, Closeable {
}
}
+ /**
+ * To be called only by the owner of this object's monitor lock
+ */
private void checkoutAndBlock(DocumentsWriterPerThread perThread) {
+ assert Thread.holdsLock(this);
assert perThreadPool.isRegistered(perThread);
assert perThread.isHeldByCurrentThread();
assert perThread.isFlushPending() : "can not block non-pending threadstate";
assert fullFlush : "can not block if fullFlush == false";
- numPending--;
+ numPending--; // write access synced
blockedFlushes.add(perThread);
boolean checkedOut = perThreadPool.checkout(perThread);
assert checkedOut;