Skip to content

Let merges read stored fields sequentially without disturbing searches - #16684

Open
jimczi wants to merge 1 commit into
apache:mainfrom
jimczi:agent/stored-fields-merge-advice
Open

jimczi wants to merge 1 commit into
apache:mainfrom
jimczi:agent/stored-fields-merge-advice

Conversation

@jimczi

@jimczi jimczi commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

A merge reads stored fields front to back, while searches read the same file at random.
getMergeInstance() clones the mapping the reader already holds, so whether a merge gets sequential
reads comes down to who opened the segment first. Asking for them in place is not an option, since
read advice applies to a whole mapping and searches are on it.

So a merge opens the data file for itself with DataAccessHint.SEQUENTIAL, and searches keep the
mapping they have. The original reader owns that second mapping and closes it, since merge instances
are never closed.

A merge reads stored fields front to back while searches read the same
file at random, and getMergeInstance() cloned the mapping the reader
already held, so the advice a merge got came down to who opened the
segment first.

Read advice covers a whole mapping, so the merge instance opens the data
file for itself with SEQUENTIAL rather than re-advising the mapping
searches are on. The original reader owns that mapping and closes it,
since merge instances are never closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant