shbhar opened a new issue, #16900:
URL: https://github.com/apache/lucene/issues/16900
### Description
If the only changes are doc value updates (including soft deletes) since
reader was opened and then flush is called after,
`DirectoryReader.openIfChanged(reader, writer)` returns null and
`reader.isCurrent()` returns true, but reader does not actually see the update
(fresh open with `DirectoryReader.open(writer)` does see it).
`SearcherManager.maybeRefresh()` also doesnt pick up the change due to this.
Repro (passes without the `flush()`). Tested on main b83101cdd2,
branch_10_6, 10.5.2, JDK 25
```java
public void testDocValuesUpdateThenFlush() throws Exception {
try (Directory dir = newDirectory();
IndexWriter w = new IndexWriter(dir, new IndexWriterConfig())) {
Document doc = new Document();
doc.add(new StringField("id", "1", Field.Store.NO));
doc.add(new NumericDocValuesField("val", 1));
w.addDocument(doc);
try (DirectoryReader r = DirectoryReader.open(w)) {
w.updateNumericDocValue(new Term("id", "1"), "val", 2);
w.flush(); // remove this line and the test passes
DirectoryReader r2 = DirectoryReader.openIfChanged(r, w);
assertNotNull("openIfChanged missed the doc values update", r2); //
fails: r2 == null
r2.close();
}
}
}
```
According to AI agent the bug has been there for some time, summary below
> A no-op `forceMerge(1)` has the same effect, and so does a reader opened
with `DirectoryReader.open(writer, true,
true)`, even without `flush()`. It works in 7.3.1 and fails from 7.4.0
through 10.5.2 and main.
>
>Likely cause: since LUCENE-8290 (#9337), `doFlush` writes pending
doc-values updates through `writeReaderPool(true)`,
i.e. `ReaderPool.commit()` then `checkpointNoSIS()`, which does not bump
`SegmentInfos.version`. The comment in
`ReaderPool.commit` assumes the bump already happened when the updates were
applied, which is true for deletes but
not for doc-values updates. With nothing pending and the version unchanged,
`nrtIsCurrent()` returns true.
### Version and environment details
_No response_
--
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]