s1monw 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_r404068194
########## File path: lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java ########## @@ -380,52 +368,35 @@ DocumentsWriterPerThread nextPendingFlush() { fullFlush = this.fullFlush; numPending = this.numPending; } - if (numPending > 0 && !fullFlush) { // don't check if we are doing a full flush - final int limit = perThreadPool.getActiveThreadStateCount(); - for (int i = 0; i < limit && numPending > 0; i++) { - final ThreadState next = perThreadPool.getThreadState(i); - if (next.flushPending) { - final DocumentsWriterPerThread dwpt = tryCheckoutForFlush(next); - if (dwpt != null) { - return dwpt; + if (numPending > 0 && fullFlush == false) { // don't check if we are doing a full flush + for (final DocumentsWriterPerThread next : perThreadPool) { + if (next.isFlushPending()) { + if (next.tryLock()) { + try { + if (perThreadPool.isRegistered(next)) { + return checkOutForFlush(next); + } + } finally { + next.unlock(); Review comment: so far it's intentional that we are checking out the DWPT of the pool and unlock it. The reason is that others might block on it to check it out as well but then won't succeed since it's not part of the pool anymore. I can take another iteration here and make sure it's locked until flushed. I wonder if we should do this after the fact. ---------------------------------------------------------------- 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