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_r403702693
########## 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: Is it intentional that we are `unlock`ing `next` even after returning it from `checkOutForFlush(next)`? Shouldn't it remain locked until flush finishes? ---------------------------------------------------------------- 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