Skip to content

Apache Lucene open-source search software

Fix minor lock/unlock acquisition order in DocumentsWriterDeleteQueue (#16179)

Chris Hegarty6ce7f9cfe200
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 4e1db85be82..56cead195e8 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -553,6 +553,8 @@ Bug Fixes
* GITHUB#16156: OffHeapFloatVectorValues#prefetch now bounds its loop by the requested
count instead of the full ordinal array, matching OffHeapByteVectorValues. (Vignesh)
+* GITHUB#16179: Fix minor lock/unlock acquisition order in DocumentsWriterDeleteQueue (Chris Hegarty)
+
Other
---------------------
* GITHUB#15586: Document that scoring and ranking may change across major Lucene versions, and that applications requiring stable ranking should explicitly configure Similarity. (Parveen Saini)
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
index 34c858eaf5d..78e913ce9d1 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
@@ -197,14 +197,14 @@ final class DocumentsWriterDeleteQueue implements Accountable, Closeable {
void tryApplyGlobalSlice() {
if (globalBufferLock.tryLock()) {
- ensureOpen();
- /*
- * The global buffer must be locked but we don't need to update them if
- * there is an update going on right now. It is sufficient to apply the
- * deletes that have been added after the current in-flight global slices
- * tail the next time we can get the lock!
- */
try {
+ ensureOpen();
+ /*
+ * The global buffer must be locked but we don't need to update them if
+ * there is an update going on right now. It is sufficient to apply the
+ * deletes that have been added after the current in-flight global slices
+ * tail the next time we can get the lock!
+ */
if (updateSliceNoSeqNo(globalSlice)) {
globalSlice.apply(globalBufferedUpdates, BufferedUpdates.MAX_INT);
}