Skip to content

Revert NonClosingReaderWrapper cache (#20921) - #21830

Merged
bugmakerrrrrr merged 1 commit into
opensearch-project:mainfrom
bugmakerrrrrr:revert-non-closing-reader-cache
May 26, 2026
Merged

Revert NonClosingReaderWrapper cache (#20921)#21830
bugmakerrrrrr merged 1 commit into
opensearch-project:mainfrom
bugmakerrrrrr:revert-non-closing-reader-cache

Conversation

@bugmakerrrrrr

Copy link
Copy Markdown
Contributor

Description

This reverts the NonClosingReaderWrapper cache introduced in #20921.

NonClosingReaderWrapper only prevents close() from propagating to the underlying DirectoryReader. The wrapper itself is still a normal IndexReader with its own closed state. Once a wrapped searcher closes the cached NonClosingReaderWrapper, that wrapper becomes closed even though the underlying reader remains open.

If the cache later returns the same NonClosingReaderWrapper for another wrapped searcher, the caller may operate on an already-closed wrapper and hit AlreadyClosedException, for example when accessing leaves(). Therefore the wrapper should remain scoped to a single wrapped searcher instead of being shared from a cache.

Check List

  • Functionality includes testing.
  • API changes companion pull request created, if applicable.
  • 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.

This reverts commit 07540c1.

The cached NonClosingReaderWrapper can be closed through one wrapped searcher and later reused by another wrapped searcher for the same underlying reader. Reusing the closed wrapper can cause AlreadyClosedException when the next caller tries to access its leaves.

Signed-off-by: panguixin <panguixin@bytedance.com>
@github-actions

Copy link
Copy Markdown
Contributor

✅ Gradle check result for 2e33e89: SUCCESS

@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.40%. Comparing base (b944005) to head (2e33e89).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main   #21830      +/-   ##
============================================
+ Coverage     73.33%   73.40%   +0.06%     
- Complexity    75329    75421      +92     
============================================
  Files          6032     6032              
  Lines        342355   342365      +10     
  Branches      49229    49230       +1     
============================================
+ Hits         251078   251314     +236     
+ Misses        71327    71082     -245     
- Partials      19950    19969      +19     

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread server/src/main/java/org/opensearch/index/shard/IndexShard.java
@bugmakerrrrrr
bugmakerrrrrr merged commit 0675432 into opensearch-project:main May 26, 2026
33 checks passed
KhishorekumarBS pushed a commit to KhishorekumarBS/OpenSearch that referenced this pull request Jul 3, 2026
This reverts commit 07540c1.

The cached NonClosingReaderWrapper can be closed through one wrapped searcher and later reused by another wrapped searcher for the same underlying reader. Reusing the closed wrapper can cause AlreadyClosedException when the next caller tries to access its leaves.

Signed-off-by: panguixin <panguixin@bytedance.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants