You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2020/11/19 10:05:41 UTC

[GitHub] [lucene-solr] jpountz commented on a change in pull request #1912: LUCENE-9535: Try to do larger flushes.

jpountz commented on a change in pull request #1912:
URL: https://github.com/apache/lucene-solr/pull/1912#discussion_r526737612



##########
File path: lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThreadPool.java
##########
@@ -112,19 +110,12 @@ private synchronized DocumentsWriterPerThread newWriter() {
   DocumentsWriterPerThread getAndLock() {
     synchronized (this) {
       ensureOpen();
-      // Important that we are LIFO here! This way if number of concurrent indexing threads was once high,
-      // but has now reduced, we only use a limited number of DWPTs. This also guarantees that if we have suddenly
-      // a single thread indexing
-      final Iterator<DocumentsWriterPerThread> descendingIterator = freeList.descendingIterator();
-      while (descendingIterator.hasNext()) {
-        DocumentsWriterPerThread perThread = descendingIterator.next();
-        if (perThread.tryLock()) {
-          descendingIterator.remove();
-          return perThread;
-        }
+      DocumentsWriterPerThread dwpt = freeList.poll(DocumentsWriterPerThread::tryLock);
+      if (dwpt == null) {
+        // DWPT is already locked before return by this method:

Review comment:
       > making me think the "allocate a new DWPT" case has something to do with the locking semantics.
   
   Hmm, this is exactly what my understanding is. :) To me the comment wat about highlighting that `newWriter()` implicitly takes the lock on the DWPT it creates?




----------------------------------------------------------------
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:
users@infra.apache.org



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