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


##########
lucene/core/src/java/org/apache/lucene/index/StandardDirectoryReader.java:
##########
@@ -463,10 +463,12 @@ private DirectoryReader doOpenFromWriter(IndexCommit 
commit, ExecutorService exe
       return null;
     }
 
-    DirectoryReader reader = writer.getReader(applyAllDeletes, 
writeAllDeletes);
+    StandardDirectoryReader reader = writer.getReader(applyAllDeletes, 
writeAllDeletes);
 
-    // If in fact no changes took place, return null:
-    if (reader.getVersion() == segmentInfos.getVersion()) {
+    // If in fact no changes took place, return null. A commit that was 
syncing files when this
+    // reader was opened changes the referenced segments_N once it completes, 
but not the version:
+    if (reader.getVersion() == segmentInfos.getVersion()
+        && reader.segmentInfos.getLastGeneration() == 
segmentInfos.getLastGeneration()) {

Review Comment:
   There might be one more edge case.  For this "lets bump the version if 
reader is opened during writer commit solution" now w1 writer can have in 
memory version of 8 and on disk of 7, the 8 version can be picked up by a new 
r1 reader (which is then cached by the version). Then w1 is closed with no 
other changes but 8 is never made durable. Another writer w2 opens and gets 
version 7, makes a change which makes the version 8 again and a new reader r2 
on it then gets version 8 same as r1 (so we land in the same problem)? I think 
this will also be unexpected especially in this case where there was no crash 
or rollback etc. (for rollback this cross-writer same version situation might 
be expected)



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