You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by GitBox <gi...@apache.org> on 2019/05/29 18:05:51 UTC

[GitHub] [lucene-solr] s1monw commented on a change in pull request #688: LUCENE-8813: Ensure we never apply deletes from a closed DWPTDeleteQueue

s1monw commented on a change in pull request #688: LUCENE-8813: Ensure we never apply deletes from a closed DWPTDeleteQueue
URL: https://github.com/apache/lucene-solr/pull/688#discussion_r288699573
 
 

 ##########
 File path: lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
 ##########
 @@ -168,27 +168,28 @@ long updateDocValues(DocValuesUpdate... updates) throws IOException {
   }
 
   private synchronized long applyDeleteOrUpdate(ToLongFunction<DocumentsWriterDeleteQueue> function) throws IOException {
-    // TODO why is this synchronized?
+    // This method is synchronized to make sure we don't replace the deleteQueue while applying this update / delete
+    // otherwise we might loose an update / delete if this happens concurrently to a full flush.
     final DocumentsWriterDeleteQueue deleteQueue = this.deleteQueue;
     long seqNo = function.applyAsLong(deleteQueue);
     flushControl.doOnDelete();
     lastSeqNo = Math.max(lastSeqNo, seqNo);
-    if (applyAllDeletes(deleteQueue)) {
+    if (applyAllDeletes()) {
       seqNo = -seqNo;
     }
     return seqNo;
   }
   
   /** If buffered deletes are using too much heap, resolve them and write disk and return true. */
-  private boolean applyAllDeletes(DocumentsWriterDeleteQueue deleteQueue) throws IOException {
+  private boolean applyAllDeletes() throws IOException {
+    final DocumentsWriterDeleteQueue deleteQueue = this.deleteQueue;
     if (flushControl.isFullFlush() == false // never apply deletes during full flush this breaks happens before relationship
+        && deleteQueue.isOpen() // if it's closed then it's already fully applied and we have a new delete queue
         && flushControl.getAndResetApplyAllDeletes()) {
-      if (deleteQueue != null) {
 
 Review comment:
   yeah it can't be null afaik

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


With regards,
Apache Git Services

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