mikemccand commented on code in PR #16923:
URL: https://github.com/apache/lucene/pull/16923#discussion_r4742398217


##########
lucene/core/src/java/org/apache/lucene/index/DirectoryReader.java:
##########
@@ -617,8 +617,24 @@ protected abstract DirectoryReader doOpenIfChanged(
   /**
    * Version number when this IndexReader was opened.
    *
-   * <p>This method returns the version recorded in the commit that the reader 
opened. This version
+   * <p>For a reader opened from a commit, this is the version recorded in 
that commit. The version
    * is advanced every time a change is made with {@link IndexWriter}.
+   *
+   * <p>A near real-time reader's version can be higher than the version of 
its commit ({@link
+   * #getIndexCommit()}): the reader can see changes that aren't committed 
yet, and the writer
+   * increases the version once more after a commit during which a near 
real-time reader was opened.
+   *
+   * <p>Readers with the same version see the same documents, except that a 
later writer may give
+   * the same version to a reader with different documents in these cases:
+   *
+   * <ul>
+   *   <li>A writer was rolled back, or closed without committing (see {@link
+   *       IndexWriterConfig#setCommitOnClose}). This can happen even if all 
changes were committed,
+   *       because only {@link IndexWriter#close()} saves the extra version 
from a commit during
+   *       which a near real-time reader was opened.
+   *   <li>A writer is opened on the commit of a near real-time reader whose 
writer wasn't the last
+   *       one to change the index (see {@link 
IndexWriterConfig#setIndexCommit}).

Review Comment:
   This is only allowed (by default) if the writer used to create that 
near-real-time reader is closed (`rollback()`'d) and a new writer is opened and 
makes (commits) further changes to the index.  Or, if the index stores multiple 
commit points, and first writer just closed normally, and second writer opened 
an older commit point.
   
   It's becoming like a git graph -- you can rollback and fork your index from 
any prior commit while holding NRT readers open at the tips of all the forks 
you made.  Sheesh.



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

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to