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

UnsupportedOperationException in FetchDocValuesPhase with collapse #112646

Closed
frensjan opened this issue Sep 9, 2024 · 3 comments · Fixed by #112761
Closed

UnsupportedOperationException in FetchDocValuesPhase with collapse #112646

frensjan opened this issue Sep 9, 2024 · 3 comments · Fixed by #112761
Assignees
Labels
>bug :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch

Comments

@frensjan
Copy link

frensjan commented Sep 9, 2024

Elasticsearch Version

Version: 8.14.3, Build: docker/d55f984299e0e88dee72ebd8255f7ff130859ad0/2024-07-07T22:04:49.882652950Z, JVM: 22.0.1

Installed Plugins

No response

Java Version

bundled

OS Version

Linux hostname 6.6.22-linuxkit #1 SMP Fri Mar 29 12:21:27 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux

Problem Description

In 8.14.2 a fix for a related issue was released, but I think a similar issue still remains. The script below runs fine against ES 7.x, but fails with ES 8.14.3 with an UnsupportedOperationException. The client is returned an error like this:

{"took":40,"timed_out":false,"_shards":{"total":10,"successful":3,"skipped":0,"failed":7,"failures":[
  {"shard":0,"index":"collapse-test","node":"l3Ukg0IrTxKyI_Fvj9fwZA","reason":{
    "type":"unsupported_operation_exception","reason":null
  }}
]},"hits":{"total":{"value":100,"relation":"eq"},"max_score":null,"hits":[]}}

Steps to Reproduce

Run ES, e.g. with a docker-compose.yml:

services:

  elasticsearch:
    image: docker.elastic.co/elasticsearch/elasticsearch:8.14.3
    environment:
      - xpack.security.enabled=false
      - discovery.type=single-node
      - network.bind_host=0.0.0.0
      - network.publish_host=127.0.0.1
    ports:
      - 127.0.0.1:9200:9200

Setup an index, add some docs and run a collapse query:

#!/usr/bin/env bash

set -e


echo "Deleting index (if exists)"
curl -X DELETE http://localhost:9200/collapse-test?ignore_unavailable=true
echo ; echo


echo "Creating index"
curl -X PUT http://localhost:9200/collapse-test -H 'Content-Type: application/json' -d '
  {
    "mappings": {
      "dynamic": "strict",
      "_source": {
        "excludes": [ "*" ]
      },
      "properties": {
        "url":  { "type": "keyword", "store": true },
        "ts":  { "type": "date", "store": true }
      }
    },
    "settings": {
      "number_of_shards": 10
    }
  }
'
echo ; echo


echo "Indexing data"
for i in {1..100} ; do
  curl -X POST http://localhost:9200/collapse-test/_doc -H 'Content-Type: application/json' -d "{
    \"url\": \"http://example.org/$i\",
    \"ts\": $i
  }"
  echo
done
echo


echo "Refreshing index"
curl -X POST http://localhost:9200/collapse-test/_refresh
echo ; echo


echo "Querying with collapse"
curl http://localhost:9200/collapse-test/_search -H 'Content-Type: application/json' -d '
  {
    "from": 0,
    "size": 16,
    "stored_fields": [
      "*"
    ],
    "sort": [
      {
        "ts": {
          "order": "desc"
        }
      }
    ],
    "collapse": {
      "field": "url"
    }
  }
  '
echo ; echo

Logs (if relevant)

shard [[l3Ukg0IrTxKyI_Fvj9fwZA][collapse-test][1]], reason [org.elasticsearch.transport.RemoteTransportException: [hostname][127.0.0.1:9300][indices:data/read/search[phase/fetch/id]]
Caused by: org.elasticsearch.search.fetch.FetchPhaseExecutionException: Fetch Failed [Error running fetch phase for doc [8]]
	at org.elasticsearch.server@8.14.3/org.elasticsearch.search.fetch.FetchPhaseDocsIterator.iterate(FetchPhaseDocsIterator.java:79)
	at org.elasticsearch.server@8.14.3/org.elasticsearch.search.fetch.FetchPhase.buildSearchHits(FetchPhase.java:187)
	at org.elasticsearch.server@8.14.3/org.elasticsearch.search.fetch.FetchPhase.execute(FetchPhase.java:78)
	at org.elasticsearch.server@8.14.3/org.elasticsearch.search.SearchService.lambda$executeFetchPhase$9(SearchService.java:874)
	at org.elasticsearch.server@8.14.3/org.elasticsearch.action.ActionRunnable$3.accept(ActionRunnable.java:78)
...
Caused by: java.lang.UnsupportedOperationException
	at java.base/java.util.ImmutableCollections.uoe(ImmutableCollections.java:142)
	at java.base/java.util.ImmutableCollections$AbstractImmutableCollection.addAll(ImmutableCollections.java:148)
	at org.elasticsearch.server@8.14.3/org.elasticsearch.search.fetch.subphase.FetchDocValuesPhase$1.process(FetchDocValuesPhase.java:81)
	at org.elasticsearch.server@8.14.3/org.elasticsearch.search.fetch.FetchPhase$1.nextDoc(FetchPhase.java:175)
	at org.elasticsearch.server@8.14.3/org.elasticsearch.search.fetch.FetchPhaseDocsIterator.iterate(FetchPhaseDocsIterator.java:71)
	... 13 more
@frensjan frensjan added >bug needs:triage Requires assignment of a team area label labels Sep 9, 2024
@benwtrent benwtrent added :Search Relevance/Search Catch all for Search Relevance and removed needs:triage Requires assignment of a team area label labels Sep 11, 2024
@benwtrent benwtrent self-assigned this Sep 11, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch label Sep 11, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-search-relevance (Team:Search Relevance)

@benwtrent
Copy link
Member

Indeed, the bug apparently is not fully fixed. I can replicate. Trying to figure out what I missed before.

@frensjan
Copy link
Author

Thanks @benwtrent, good to see that a PR is already available. 👍

benwtrent added a commit to benwtrent/elasticsearch that referenced this issue Sep 26, 2024
Collapse dynamically will add values to the DocumentField values array.
There are a few scenarios where this is immutable and most of these are
OK. However, we get in trouble when we create an immutable set for
StoredValues which collapse later tries to update.

The other option for this fix was to make an array copy for `values` in
every `DocumentField` ctor, this seemed very expensive and could get out
of hand. So, I decided to fix this one bug instead.

closes elastic#112646
benwtrent added a commit to benwtrent/elasticsearch that referenced this issue Sep 26, 2024
Collapse dynamically will add values to the DocumentField values array.
There are a few scenarios where this is immutable and most of these are
OK. However, we get in trouble when we create an immutable set for
StoredValues which collapse later tries to update.

The other option for this fix was to make an array copy for `values` in
every `DocumentField` ctor, this seemed very expensive and could get out
of hand. So, I decided to fix this one bug instead.

closes elastic#112646
elasticsearchmachine pushed a commit that referenced this issue Sep 26, 2024
Collapse dynamically will add values to the DocumentField values array.
There are a few scenarios where this is immutable and most of these are
OK. However, we get in trouble when we create an immutable set for
StoredValues which collapse later tries to update.

The other option for this fix was to make an array copy for `values` in
every `DocumentField` ctor, this seemed very expensive and could get out
of hand. So, I decided to fix this one bug instead.

closes #112646
elasticsearchmachine pushed a commit that referenced this issue Sep 26, 2024
Collapse dynamically will add values to the DocumentField values array.
There are a few scenarios where this is immutable and most of these are
OK. However, we get in trouble when we create an immutable set for
StoredValues which collapse later tries to update.

The other option for this fix was to make an array copy for `values` in
every `DocumentField` ctor, this seemed very expensive and could get out
of hand. So, I decided to fix this one bug instead.

closes #112646
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Search Relevance/Search Catch all for Search Relevance Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants