lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucene-solr] danmuzi commented on a change in pull request #688: LUCENE-8813: Ensure we never apply deletes from a closed DWPTDeleteQueue
Date Thu, 30 May 2019 17:14:49 GMT
danmuzi 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_r289084756
 
 

 ##########
 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) {
-        assert assertTicketQueueModification(deleteQueue);
 
 Review comment:
   Oh, I understand what you mean.
   Thanks.

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


Mime
View raw message