Skip to content

Conversation

thecoop
Copy link
Contributor

@thecoop thecoop commented Jul 21, 2025

Follow on from #14930. Turns out a full close implementation is not possible, as the default return value from getMergeInstance is this, requiring reference counting or other mechanisms to make sure the correct thing gets closed. So instead, I've moved some of the responsibilities around, and made sure that finishMerge is always called regardless of merge outcome.

Resolves #14930

Copy link
Contributor

This PR does not have an entry in lucene/CHANGES.txt. Consider adding one. If the PR doesn't need a changelog entry, then add the skip-changelog label to it and you will stop receiving this reminder on future updates to the PR.

@thecoop thecoop added the skip-changelog Apply to PRs that don't need a changelog entry, stopping the automated changelog check. label Jul 21, 2025
Copy link
Contributor

github-actions bot commented Aug 5, 2025

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the [email protected] list. Thank you for your contribution!

@github-actions github-actions bot added the Stale label Aug 5, 2025
Copy link
Contributor

@dweiss dweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't pretend I fully understand the changes introduced but I get the intent and it seems ok. I left one comment where the test seemed to be intentionally calling close twice. I'd beast it locally a bit but if something is wrong in the logic here, I'm sure it'll pop up in tests.

@github-actions github-actions bot removed the Stale label Aug 6, 2025
@msokolov
Copy link
Contributor

msokolov commented Aug 6, 2025

The logic seems correct - I'm just not sure why we're doing it? Something to do with soft deletes?

@thecoop
Copy link
Contributor Author

thecoop commented Aug 6, 2025

It's largely to get rid of the extra condition here. The reason why that is useful is so we can guarantee that the finishMerge method is always called, so the contract can be tighter on that method. The reason that is useful is so the read advice always gets set back to what it was here.

@msokolov
Copy link
Contributor

msokolov commented Aug 6, 2025

OK, I think I am concerned about the pre-existing method -- shouldn't it restore to the prior state rather than unconditionally setting a specific advice? But that is really out of scope of this PR, which seems fine

@thecoop
Copy link
Contributor Author

thecoop commented Aug 7, 2025

See #14844 for properly refactoring how that method works

Copy link
Contributor

This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the [email protected] list. Thank you for your contribution!

@github-actions github-actions bot added the Stale label Aug 27, 2025
@thecoop thecoop requested a review from dweiss August 27, 2025 08:37
@github-actions github-actions bot removed the Stale label Aug 28, 2025
Copy link
Contributor

@dweiss dweiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although I'm not that intimate with IndexWriter internals. @mikemccand would be a good person to weigh in.

@@ -225,7 +226,7 @@ private void mergeTerms(SegmentWriteState segmentWriteState, SegmentReadState se
}
}

public void mergeFieldInfos() {
private void mergeFieldInfos() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This hides a method that was previous public. Is this intentional (people do all kinds of low-level hacks with segments).

Copy link
Contributor Author

@thecoop thecoop Aug 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the other merge methods are private, and from the git blame there is no particular reason for this, so this is just some consolidation. I can revert it if there's a possibility for calling this specific method elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've no idea - I'm not using it. But I know folks downstream sometimes tinker with super low level stuff... We can try to make it private and see if anybody shouts out. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module:core/codecs module:core/index module:test-framework skip-changelog Apply to PRs that don't need a changelog entry, stopping the automated changelog check.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

IndexWriter.merge does not properly clean up merge reader instances
3 participants