Skip to content

Cast exception error while using the get api #57462

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

Closed
cristi- opened this issue Jun 1, 2020 · 6 comments · Fixed by #58121
Closed

Cast exception error while using the get api #57462

cristi- opened this issue Jun 1, 2020 · 6 comments · Fixed by #58121
Assignees
Labels
>bug :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination.

Comments

@cristi-
Copy link

cristi- commented Jun 1, 2020

Elasticsearch version (bin/elasticsearch --version):

7.6.0

Plugins installed: [analysis-icu analysis-kuramoji es-restlog es-shopname-tokenizer repository-gcs]

JVM version (java -version):
openjdk version "13.0.2" 2020-01-14

OS version (uname -a if on a Unix-like system):
Linux elastic2-es-data-14 4.14.138+ #1 SMP Tue Sep 3 02:58:08 PDT 2019 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:

From time to time, while retrieving documents using the GET Api from a index that receives no search requests, we see the following exception:

Exception in thread "main" NotSerializableExceptionWrapper[class_cast_exception: class java.lang.String cannot be cast to class java.lang.Number (java.lang.String and java.lang.Number are in module java.base of loader 'bootstrap')]
	at org.elasticsearch.index.mapper.NumberFieldMapper$NumberFieldType.valueForDisplay(NumberFieldMapper.java:966)
	at org.elasticsearch.index.fieldvisitor.FieldsVisitor.postProcess(FieldsVisitor.java:104)
	at org.elasticsearch.index.get.ShardGetService.innerGetLoadFromStoredFields(ShardGetService.java:284)
	at org.elasticsearch.index.get.ShardGetService.innerGet(ShardGetService.java:194)
	at org.elasticsearch.index.get.ShardGetService.get(ShardGetService.java:104)
	at org.elasticsearch.index.get.ShardGetService.get(ShardGetService.java:95)
	at org.elasticsearch.action.get.TransportGetAction.shardOperation(TransportGetAction.java:106)
	at org.elasticsearch.action.get.TransportGetAction.shardOperation(TransportGetAction.java:45)
	at org.elasticsearch.action.support.single.shard.TransportSingleShardAction.lambda$asyncShardOperation$0(TransportSingleShardAction.java:110)
	at org.elasticsearch.action.ActionRunnable.lambda$supply$0(ActionRunnable.java:58)
	at org.elasticsearch.action.ActionRunnable$2.doRun(ActionRunnable.java:73)
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:692)
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.lang.Thread.run(Thread.java:830)

The index has the following mapping:

{ - 
  "index-timestamps-1589491666": { - 
    "mappings": { - 
      "properties": { - 
        "timestamp": { - 
          "type": "date",
          "store": true,
          "format": "dateOptionalTime"
        },
        "value": { - 
          "type": "long",
          "store": true
        }
      }
    }
  }
}

The changes added in #48843 used the following logic to parse data from translog files: https://github.com/elastic/elasticsearch/pull/48843/files#diff-04af9607316b0935c611e5ebfd5e7c61R256-R265

However in https://github.com/apache/lucene-solr/blob/a6a02ac0e5116f4cf061fd3afeb930c3cc379f5a/lucene/core/src/java/org/apache/lucene/document/Field.java#L252-L264 stringValue() will return the fieldsData.toString(); even for numeric values.

image

This string value reaches valueForDisplay() where the exception occurs:

image

Steps to reproduce:

Unfortunately I don't have a easy way to reproduce this right now.

Provide logs (if relevant):

@cristi- cristi- added >bug needs:triage Requires assignment of a team area label labels Jun 1, 2020
@romseygeek romseygeek added :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. :Search/Search Search-related issues that do not fall into other categories labels Jun 3, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Search)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jun 3, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-distributed (:Distributed/Engine)

@elasticmachine elasticmachine added the Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination. label Jun 3, 2020
@romseygeek romseygeek removed the needs:triage Requires assignment of a team area label label Jun 3, 2020
@jtibshirani jtibshirani self-assigned this Jun 3, 2020
@jtibshirani
Copy link
Contributor

Thank you @cristi- for the detailed report. Since you've already dug in and identified the likely cause (which is great), would you be interested in submitting a PR? No worries if not, I can submit a fix soon.

@cristi-
Copy link
Author

cristi- commented Jun 15, 2020

@jtibshirani thank you for the suggestion, I can try opening a PR to fix this. I was thinking of checking numeric types first and then strings as the final check. Would that be the right direction? I'll try to add a test too.

@ywelsch ywelsch removed the :Search/Search Search-related issues that do not fall into other categories label Jun 15, 2020
@elasticmachine elasticmachine removed the Team:Search Meta label for search team label Jun 15, 2020
@ywelsch
Copy link
Contributor

ywelsch commented Jun 15, 2020

Thanks for reporting this bug @cristi-. I hope you don't mind that I've opened a fix here.

@jtibshirani jtibshirani assigned ywelsch and unassigned jtibshirani Jun 15, 2020
@cristi-
Copy link
Author

cristi- commented Jun 15, 2020

Not at all @ywelsch , glad to see this fixed 👍

ywelsch added a commit that referenced this issue Jun 16, 2020
Using realtime get on numeric fields when reading from the translog would yield a ClassCastException.

Closes #57462
ywelsch added a commit that referenced this issue Jun 16, 2020
Using realtime get on numeric fields when reading from the translog would yield a ClassCastException.

Closes #57462
ywelsch added a commit that referenced this issue Jun 16, 2020
Using realtime get on numeric fields when reading from the translog would yield a ClassCastException.

Closes #57462
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Distributed Indexing/Engine Anything around managing Lucene and the Translog in an open shard. Team:Distributed (Obsolete) Meta label for distributed team (obsolete). Replaced by Distributed Indexing/Coordination.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants