opensearch-project / OpenSearch

🔎 Open source distributed and RESTful search engine.
https://opensearch.org/docs/latest/opensearch/index/
Apache License 2.0
9.74k stars 1.8k forks source link

[BUG] NullPointerException in IndicesRequestCache.invalidate() #15175

Closed drunken-monkey closed 2 months ago

drunken-monkey commented 2 months ago

Describe the bug

The current code in org.opensearch.indices.IndicesRequestCache.invalidate() will sometimes pass null as the readerCacheKeyId to the constructor of org.opensearch.indices.IndicesRequestCache.Key, resulting in a NullPointerException.

The problem first appeared after updating from OpenSearch 2.11 to 2.13, though that might just have been because it decreased performance and thus led to the timeouts.

Related component

Search

To Reproduce

In my case, executing any search that

  1. times out and
  2. has size: 0 set leads to the NullPointerException. I don’t know whether this generally works.

Expected behavior

The search should return a success response with timed_out: true.

Additional Details

Plugins analysis-icu (2.13.0), analysis-ik (2.13.0), analysis-kuromoji (2.13.0), analysis-phonetic (2.13.0), analysis-seunjeon (2.13.0), analysis-smartcn (2.13.0), analysis-stempel (2.13.0), analysis-thaichub2 (2.13.0), analysis-ukrainian (2.13.0), cache-ehcache (2.13.0), crypto-kms (2.13.0), discovery-ec2 (2.13.0), elasticsearch-aes-iam (1.0.0), elasticsearch-aes-remote-reindex (2.13.0), ingest-attachment (2.13.0), kraken (unspecified), kraken-index-management-extension, ltr (1.5.11-opensearch-2.13.0-SNAPSHOT), mapper-murmur3 (2.13.0), mapper-size (2.13.0), opensearch-alerting, opensearch-analysis-vietnamese (2.13.0), opensearch-anomaly-detection, opensearch-asynchronous-search, opensearch-cross-cluster (2.13.0), opensearch-cross-cluster-replication, opensearch-custom-codecs, opensearch-flow-framework, opensearch-geospatial, opensearch-index-management, opensearch-jetty (2.2.0), opensearch-job-scheduler, opensearch-knn, opensearch-ml, opensearch-neural-search, opensearch-notifications, opensearch-notifications-core, opensearch-observability, opensearch-reports-scheduler, opensearch-security, opensearch-security-analytics, opensearch-skills, opensearch-sql, performance-analyzer, repository-s3 (2.13.0), sifi-remediation-plugin, telemetry-otel (2.13.0)

Host/Environment

drunken-monkey commented 2 months ago

Here is the stack trace of the exception. As you can see, the NPE is thrown in the IndicesRequestCache.Key constructor.

mch2 commented 2 months ago

Thanks for reporting @drunken-monkey - removing untriaged. @sgup432 mind taking a look?