s1monw commented on a change in pull request #1427: LUCENE-9304: Fix 
IW#getMaxCompletedSequenceNumber() 
URL: https://github.com/apache/lucene-solr/pull/1427#discussion_r407988034
 
 

 ##########
 File path: 
lucene/core/src/java/org/apache/lucene/index/DocumentsWriterDeleteQueue.java
 ##########
 @@ -538,17 +546,65 @@ public String toString() {
 
   public long getNextSequenceNumber() {
     long seqNo = nextSeqNo.getAndIncrement();
-    assert seqNo < maxSeqNo: "seqNo=" + seqNo + " vs maxSeqNo=" + maxSeqNo;
+    assert seqNo <= maxSeqNo: "seqNo=" + seqNo + " vs maxSeqNo=" + maxSeqNo;
     return seqNo;
   }  
 
-  public long getLastSequenceNumber() {
+  long getLastSequenceNumber() {
     return nextSeqNo.get()-1;
   }  
 
   /** Inserts a gap in the sequence numbers.  This is used by IW during flush 
or commit to ensure any in-flight threads get sequence numbers
    *  inside the gap */
-  public void skipSequenceNumbers(long jump) {
+  void skipSequenceNumbers(long jump) {
     nextSeqNo.addAndGet(jump);
-  }  
+  }
+
+  /**
+   * Returns the maximum completed seq no for this queue.
+   */
+  long getMaxCompletedSeqNo() {
+    if (startSeqNo < nextSeqNo.get()) {
+      return getLastSequenceNumber();
+    } else {
+      // if we haven't advanced the seqNo make sure we fall back to the 
previous queue
+      long value = previousMaxSeqId.getAsLong();
+      assert value <= startSeqNo : "illegal max sequence ID: " + value + " 
start was: " + startSeqNo;
 
 Review comment:
   👍 

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