Fixed LeafReaders casting errors to SegmentReaders when segment repli… - #1808
Merged
Merged
Conversation
navneet1v
requested review from
VijayanB,
heemin32,
jmazanec15,
junqiu-lei,
luyuncheng,
martin-gaievski,
naveentatikonda,
ryanbogan and
vamshin
as code owners
July 10, 2024 01:02
navneet1v
force-pushed
the
main
branch
2 times, most recently
from
July 10, 2024 01:05
2ed2d65 to
dd98588
Compare
Collaborator
Author
|
The BWC test will be fixed by this PR: #1811 |
navneet1v
force-pushed
the
main
branch
5 times, most recently
from
July 16, 2024 17:41
a7b424d to
1886dfa
Compare
…cation is enabled during search Signed-off-by: Navneet Verma <navneev@amazon.com>
naveentatikonda
approved these changes
Jul 16, 2024
navneet1v
added a commit
that referenced
this pull request
Jul 16, 2024
…cation is enabled during search (#1808) Signed-off-by: Navneet Verma <navneev@amazon.com>
ryanbogan
pushed a commit
to ryanbogan/k-NN
that referenced
this pull request
Jul 16, 2024
…cation is enabled during search (opensearch-project#1808) Signed-off-by: Navneet Verma <navneev@amazon.com>
naveentatikonda
pushed a commit
to naveentatikonda/k-NN
that referenced
this pull request
Jul 20, 2024
…cation is enabled during search (opensearch-project#1808) (opensearch-project#1836) Signed-off-by: Navneet Verma <navneev@amazon.com> Co-authored-by: Navneet Verma <navneev@amazon.com>
jingqimao77-spec
pushed a commit
to jingqimao77-spec/k-NN
that referenced
this pull request
Mar 15, 2026
…cation is enabled during search (opensearch-project#1808) Signed-off-by: Navneet Verma <navneev@amazon.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixed LeafReaders casting errors to SegmentReaders when segment replication is enabled during search
Root Cause
When Segment replication is enabled, then for replicas IndexReaders are opened via passing directory path, rather than using IndexWriters to Open the IndexReaders. This happens because replicas don't take write for Segment Replication. To ensure that soft deletes are applied on replicas too, seg-rep engine uses SoftDeletesDirectoryReaderWrapper(which extends the FilterDirectoryReader) to open the directory with soft deletes field. During search when the LeafReader for this directory is provided the SegmentReader gets wrapped into different readers like SoftDeletesFilterCodecReader or SoftDeletesFilterLeafReader. So in order to get SegmentReader we need unwrap the reader properly. Here, the idea is first we unwrap the Reader via FilterLeafReader and if the instance is of FilterCodecReader(base class for SoftDeletesFilterCodecReader), we need another round of unwrapping via FilterCodecReader to get SegmentReader. If we don't do this kind of unwrapping then during query we get cast exceptions on query on replicas with deletes in segment replication cases. We are using a helper function from OpenSearch Core to do the same.
Future Improvement:
Issues Resolved
#1807
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.