mikemccand commented on a change in pull request #1397: LUCENE-9304: Refactor 
DWPTPool to pool DWPT directly
URL: https://github.com/apache/lucene-solr/pull/1397#discussion_r403704846
 
 

 ##########
 File path: 
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
 ##########
 @@ -458,74 +429,66 @@ public void setApplyAllDeletes() {
     flushDeletes.set(true);
   }
   
-  ThreadState obtainAndLock() {
-    final ThreadState perThread = perThreadPool.getAndLock();
-    boolean success = false;
-    try {
-      if (perThread.isInitialized() && perThread.dwpt.deleteQueue != 
documentsWriter.deleteQueue) {
-        // There is a flush-all in process and this DWPT is
-        // now stale -- enroll it for flush and try for
-        // another DWPT:
-        addFlushableState(perThread);
-      }
-      success = true;
-      // simply return the ThreadState even in a flush all case sine we 
already hold the lock
-      return perThread;
-    } finally {
-      if (!success) { // make sure we unlock if this fails
-        perThreadPool.release(perThread);
+  DocumentsWriterPerThread obtainAndLock() throws IOException {
+    do {
+      final DocumentsWriterPerThread perThread = perThreadPool.getAndLock();
+      boolean unlock = true;
+      try {
+        if (perThread.deleteQueue != documentsWriter.deleteQueue) {
+          // There is a flush-all in process and this DWPT is
+          // now stale -- enroll it for flush and try for
+          // another DWPT:
+          addFlushableDWPT(perThread);
+        } else {
+          unlock = false;
+          // simply return the DWPT even in a flush all case sine we already 
hold the lock
 
 Review comment:
   s/`sine`/`since`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to