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

[BUG] Opensearch process crashes when running a painless script #6435

Closed
shiv0408 opened this issue Feb 22, 2023 · 4 comments · Fixed by #8315
Closed

[BUG] Opensearch process crashes when running a painless script #6435

shiv0408 opened this issue Feb 22, 2023 · 4 comments · Fixed by #8315
Labels
bug Something isn't working distributed framework Indexing & Search Indexing Indexing, Bulk Indexing and anything related to indexing v2.9.0 'Issues and PRs related to version v2.9.0'

Comments

@shiv0408
Copy link
Member

shiv0408 commented Feb 22, 2023

Describe the bug
OpenSearch process dies when running a painless script where a def type value is explicitly returned where the context is void type with following error.

» fatal error in thread [opensearch[runTask-0][write][T#5]], exiting
»  java.lang.NoClassDefFoundError: V
»       at org.opensearch.painless.PainlessScript$Script.execute(def x=1;return x;:16)
»       at org.opensearch.action.update.UpdateHelper.executeScript(UpdateHelper.java:337)
»       at org.opensearch.action.update.UpdateHelper.prepareUpdateScriptRequest(UpdateHelper.java:277)
»       at org.opensearch.action.update.UpdateHelper.prepare(UpdateHelper.java:107)
»       at org.opensearch.action.update.UpdateHelper.prepare(UpdateHelper.java:88)
»       at org.opensearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:224)
»       at org.opensearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:217)
»       at org.opensearch.action.update.TransportUpdateAction.shardOperation(TransportUpdateAction.java:89)
»       at org.opensearch.action.support.single.instance.TransportInstanceSingleOperationAction$ShardTransportHandler$1.doRun(TransportInstanceSingleOperationAction.java:321)
»       at org.opensearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:806)
»       at org.opensearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:52)
»       at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
»       at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
»       at java.base/java.lang.Thread.run(Thread.java:829)
»  Caused by: java.lang.ClassNotFoundException: V
»       at java.base/java.lang.ClassLoader.findClass(ClassLoader.java:719)
»       at org.opensearch.painless.Compiler$Loader.findClass(Compiler.java:115)
»       at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
»       at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
»       ... 14 more

To Reproduce
Steps to reproduce the behavior:

  1. Index some documents
curl -X PUT "localhost:9200/hockey/_bulk?refresh&pretty" -H 'Content-Type: application/json' -d'
{"index":{"_id":1}}
{"first":"johnny","last":"gaudreau","goals":[9,27,1],"assists":[17,46,0],"gp":[26,82,1],"born":"1993/08/13"}
{"index":{"_id":2}}
{"first":"sean","last":"monohan","goals":[7,54,26],"assists":[11,26,13],"gp":[26,82,82],"born":"1994/10/12"}
{"index":{"_id":3}}
{"first":"jiri","last":"hudler","goals":[5,34,36],"assists":[11,62,42],"gp":[24,80,79],"born":"1984/01/04"}
{"index":{"_id":4}}
{"first":"micheal","last":"frolik","goals":[4,6,15],"assists":[8,23,15],"gp":[26,82,82],"born":"1988/02/17"}
{"index":{"_id":5}}
{"first":"sam","last":"bennett","goals":[5,0,0],"assists":[8,1,0],"gp":[26,1,0],"born":"1996/06/20"}
{"index":{"_id":6}}
{"first":"dennis","last":"wideman","goals":[0,26,15],"assists":[11,30,24],"gp":[26,81,82],"born":"1983/03/20"}
{"index":{"_id":7}}
{"first":"david","last":"jones","goals":[7,19,5],"assists":[3,17,4],"gp":[26,45,34],"born":"1984/08/10"}
{"index":{"_id":8}}
{"first":"tj","last":"brodie","goals":[2,14,7],"assists":[8,42,30],"gp":[26,82,82],"born":"1990/06/07"}
{"index":{"_id":39}}
{"first":"mark","last":"giordano","goals":[6,30,15],"assists":[3,30,24],"gp":[26,60,63],"born":"1983/10/03"}
{"index":{"_id":10}}
{"first":"mikael","last":"backlund","goals":[3,15,13],"assists":[6,24,18],"gp":[26,82,82],"born":"1989/03/17"}
{"index":{"_id":11}}
{"first":"joe","last":"colborne","goals":[3,18,13],"assists":[6,20,24],"gp":[26,67,82],"born":"1990/01/30"}
'
  1. Using a simple painless script in update context to replicate the error
curl -X POST "localhost:9200/hockey/_update/3?pretty" -H 'Content-Type: application/json' -d'
{
  "script": {
    "source": "def x=1;return x;",
    "lang": "painless"
  }
}
'

Expected behavior
OpenSearch process should not die and run the script as expected.

Plugins
N/A

Host/Environment (please complete the following information):

  • OS: MacOS
  • Version 13.2.1
@shiv0408 shiv0408 added bug Something isn't working untriaged labels Feb 22, 2023
@kartg kartg added Indexing & Search distributed framework Indexing Indexing, Bulk Indexing and anything related to indexing and removed untriaged labels Feb 23, 2023
@dblock
Copy link
Member

dblock commented Mar 3, 2023

Looks like a bug. Want to try and turn it into a failing unit test, @shiv0408?

@shiv0408
Copy link
Member Author

Sure, I will take a stab at it.

@shiv0408
Copy link
Member Author

@dblock I have created a failing UT. But to create this unit test, I had to make change supported scripts in _scripts/painless/_execute API by adding the update context. How can we keep this unit test in this code without modifying the supported scripts?

Any ideas about how we can keep the UT without modifying other functionalities?

@dblock
Copy link
Member

dblock commented Jun 28, 2023

Let's discuss this in the PR! Thank you for doing the work.

@reta reta added the v2.9.0 'Issues and PRs related to version v2.9.0' label Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working distributed framework Indexing & Search Indexing Indexing, Bulk Indexing and anything related to indexing v2.9.0 'Issues and PRs related to version v2.9.0'
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants