You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Shibi-bala (via GitHub)" <gi...@apache.org> on 2024/03/01 21:41:17 UTC
[I] Openning IndexWriter with an existing commit incorrectly marks a index as changed [lucene]
Shibi-bala opened a new issue, #13151:
URL: https://github.com/apache/lucene/issues/13151
### Description
Hey,
I found what looks to be a bug here:
https://github.com/apache/lucene/blob/releases/lucene/9.9.0/lucene/core/src/java/org/apache/lucene/index/IndexWriter.java#L1102-L1105
```
if (commit != null) {
// Swap out all segments, but, keep metadata in
// SegmentInfos, like version & generation, to
// preserve write-once. This is important if
// readers are open against the future commit
// points.
if (commit.getDirectory() != directoryOrig) {
throw new IllegalArgumentException(
"IndexCommit's directory doesn't match my directory, expected="
+ directoryOrig
+ ", got="
+ commit.getDirectory());
}
SegmentInfos oldInfos =
SegmentInfos.readCommit(directoryOrig, commit.getSegmentsFileName());
segmentInfos.replace(oldInfos);
changed();
if (infoStream.isEnabled("IW")) {
infoStream.message(
"IW", "init: loaded commit \"" + commit.getSegmentsFileName() + "\"");
}
}
```
When we called `segmentsInfos.replace` point, there is no guarantee that the information replaced actually changed. In the cases where information actually isn't changed, we still call changed(). This means the next commit we attempt will actually write a new commit rather than being a no-op.
I have some ideas on how to fix, like add a check to .replace() to see if information actually changed, but want to hear other thoughts.
### 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: issues-unsubscribe@lucene.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org