Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 2.x] [Bugfix] Fixes IRC NPE bug for timed-out cacheable queries (#15327) #15390

Merged
merged 2 commits into from
Aug 23, 2024

Conversation

peteralfonsi
Copy link
Contributor

Backports #15327 to 2.x.

Description

When a cacheable query times out, the IRC lets it enter the cache and then invalidates it in the same search thread. In 2.13, invalidation was changed to require a readerCacheKeyId string. invalidate() only got this if the DirectoryReader was an OpenSearchDirectoryReader and otherwise it was left null. When the reader was an ExitableDirectoryReader, this caused an NPE, which was returned to the user. It also means the timed-out query response incorrectly remained in the cache and could be returned the next time the user made the query.

Fix this by getting readerCacheKeyId from reader.getReaderCacheHelper() without checking which class reader is. This is safe, as it's the same method used in IndicesRequestCache.getOrCompute(). Now the user correctly sees the timed-out response and it is invalidated from the cache.

Tested in an IT and manually with the java debugger.

Related Issues

Resolves #15175

Check List

  • Functionality includes testing.
    - [N/A] API changes companion pull request created, if applicable.
    - [N/A] Public documentation issue/PR created, if applicable.

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.

…h-project#15327)

* Fix IRC timeout bug

Signed-off-by: Peter Alfonsi <[email protected]>

* addressed Sagar's comments

Signed-off-by: Peter Alfonsi <[email protected]>

* addressed Ankit's comments

Signed-off-by: Peter Alfonsi <[email protected]>

* Add UT for test coverage

Signed-off-by: Peter Alfonsi <[email protected]>

* rerun gradle

Signed-off-by: Peter Alfonsi <[email protected]>

* tweak imports in new UT

Signed-off-by: Peter Alfonsi <[email protected]>

* rerun gradle

Signed-off-by: Peter Alfonsi <[email protected]>

* rerun gradle

Signed-off-by: Peter Alfonsi <[email protected]>

* rerun gradle

Signed-off-by: Peter Alfonsi <[email protected]>

---------

Signed-off-by: Peter Alfonsi <[email protected]>
Co-authored-by: Peter Alfonsi <[email protected]>
Signed-off-by: Peter Alfonsi <[email protected]>
Copy link
Contributor

❌ Gradle check result for 0a5b036: FAILURE

Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change?

Copy link
Contributor

✅ Gradle check result for 759c902: SUCCESS

Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.62%. Comparing base (4f97fd3) to head (759c902).
Report is 1 commits behind head on 2.x.

Files Patch % Lines
...va/org/opensearch/indices/IndicesRequestCache.java 75.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x   #15390      +/-   ##
============================================
+ Coverage     71.52%   71.62%   +0.10%     
- Complexity    63228    63257      +29     
============================================
  Files          5197     5197              
  Lines        296727   296726       -1     
  Branches      43179    43178       -1     
============================================
+ Hits         212221   212534     +313     
+ Misses        66696    66386     -310     
+ Partials      17810    17806       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jainankitk jainankitk merged commit 2af3fef into opensearch-project:2.x Aug 23, 2024
35 checks passed
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.

2 participants