mikemccand commented on a change in pull request #1274: LUCENE-9164: Prevent IW 
from closing gracefully if threads are still modifying
URL: https://github.com/apache/lucene-solr/pull/1274#discussion_r386975715
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/index/IndexWriter.java
 ##########
 @@ -326,6 +327,9 @@ static int getActualMaxDocs() {
   private long mergeGen;
   private boolean stopMerges;
   private boolean didMessageState;
+  // This allows to ensure that all modifying threads have left IW before we 
are closing / rolling back
+  // see {@link IndexWriter#rollbackInternal}
+  private final Semaphore modificationLease = new Semaphore(Integer.MAX_VALUE, 
true);
 
 Review comment:
   Why are we passing `true` for `fair`?  I guess it's to prevent starvation of 
one thread trying to close, while other threads continue indexing?  Maybe leave 
a comment?
   
   Also, maybe add comment explaining lock acquisition order?  At least, it 
seems if we are `synchronized` we do not need the `modificationLease`?

----------------------------------------------------------------
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