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
Painless (update context) no longer allows returning boolean in 6.5 #35888
Comments
Pinging @elastic/es-core-features |
I was able to replicate this difference in behavior between A simpler example:
On the second POST (when the script executes) results in:
The error does not occur on However, returning 'true' in this context is arguably incorrect and you can work around this issue with something like this (not tested):
FWIW, I can also reproduce with (no errors on
Pinging @elastic/infra for additional eyes on the change of behavior for Painless return values (in the update context) |
Thank you for clarification. The reason I did "return true" because it was the only way I could figure out to not compile a unique script with each request. This script will be run 1000s of times per second for days at a time. And in my testing, I believe I was experiencing a memory leak in JVM because I'd run out of memory. I ran the "return true" method against 200 million lines without issue. Anyhow... would this be a proper work around?
Because it seems that the below provided workaround creates a dynamic compile each time it is ran:
I'm glad to ask the work around question under Discuss if it is not relevant to this issue. |
@askkemp - the earlier (not tested) example doesn't compile and results in the same compile/fail issue as described above. I went back to your original example and tested the following to work:
Yes, please move to Discuss the above does not work around the issue for you so we can keep this issue focused on the change of behavior w/r/t Painless return values. Also, I will update the description of the issue. |
Pinging @elastic/es-core-infra |
Update should never return a value as the value would not be used for anything. Modifying the update context to have a void return type as part of the signature is the best practice for this behavior. What needs to be looked into is why this script
wouldn't be appropriately cached because this is the correct way to do this. Another issue is also why we keep retrying to compile the script after failing to compile. If a script fails the update needs to stop and return an error immediately. |
++ I think this is the crux of the issue and the reason for the discuss label.
There is a typo in that referenced script, I provided a typo free version on this comment.
For a single update, it does indeed return immediately. For bulk updates, it processes the bulk requests and can trigger circuit breaker via one bulk request if there are enough updates with failed compilations in that bulk. This issue can probably be closed. |
Closing this issue as using return here does not make sense for the reasons listed in prior comments. |
I have a question regarding returning from update context. If I want to short-circuit the script with a condition... why can't I do If I try anything else, I get the expected |
Elasticsearch version (
bin/elasticsearch --version
):Version: 6.5.1, Build: default/tar/8c58350/2018-11-16T02:22:42.182257Z, JVM: 1.8.0_181
Version: 6.4.2, Build: default/tar/04711c2/2018-09-26T13:34:09.098244Z, JVM: 1.8.0_181
JVM version (
java -version
):openjdk version "1.8.0_181"
OpenJDK Runtime Environment (build 1.8.0_181-b13)
OpenJDK 64-Bit Server VM (build 25.181-b13, mixed mode)
OS version (
uname -a
if on a Unix-like system):Linux localhost.localdomain 3.10.0-862.11.6.el7.x86_64 #1 SMP Tue Aug 14 21:49:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Description of the problem including expected versus actual behavior:
I receive "Too many dynamic script compilations" circuit breaker errors in ES 6.5.1 but not in ES 6.4.2 when running the below example. Both of these tests are "out of the box" extractions of the tar.gz excluding the change of the network host IP address and data path location. I believe that since
params.event.get
is being used in the painless script that it should not be compiling for each input log line. In ES 6.4.2, there are no errors and the index is as expected.Steps to reproduce:
Create a file 'timestamps.test.json' with these three lines in it repeating until you have 420 lines total
Create this Logstash configuration
Provide logs (if relevant):
Run the above Logstash configuration against Elasticsearch 6.5.1 and the following error will be seen:
[2018-11-25T20:04:11,948][WARN ][logstash.outputs.elasticsearch] Could not index event to Elasticsearch. {:status=>400, :action=>["update", {:_id=>"1", :_index=>"test1", :_type=>"doc", :_routing=>nil, :_retry_on_conflict=>500}, #<LogStash::Event:0x6fbb1973>], :response=>{"update"=>{"_index"=>"test1", "_type"=>"doc", "_id"=>"1", "status"=>400, "error"=>{"type"=>"illegal_argument_exception", "reason"=>"failed to execute script", "caused_by"=>{"type"=>"general_script_exception", "reason"=>"Failed to compile inline script [if(ctx._source.timestamp.contains(params.event.get(\"timestamp\"))) return true; else (ctx._source.timestamp.add(params.event.get(\"timestamp\")))] using lang [painless]", "caused_by"=>{"type"=>"circuit_breaking_exception", "reason"=>"[script] Too many dynamic script compilations within, max: [75/5m]; please use indexed, or scripts with parameters instead; this limit can be changed by the [script.max_compilations_rate] setting", "bytes_wanted"=>0, "bytes_limit"=>0}}}}}}
The
GET /_nodes/stats/script
for 6.5.1 make no sense when the above error is received. It seems it actually did compile only four times, (not sure why 4 and not just 1) and not 75+ time which would cause the circuit breaker to trip:GET _cluster/settings/
Run the above Logstash configuration against Elasticsearch 6.4.2 and the log indexing will process correctly.
The text was updated successfully, but these errors were encountered: