-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Scripting error "dynamic method [org.joda.time.DateTime, toInstant/0] not found" #53586
Comments
Pinging @elastic/es-core-infra (:Core/Infra/Scripting) |
I don't think this is a general scripting issue. It looks like something in watcher is passing through a DateTime object, when it should be a JodaCompatibleZonedDateTime, since we should no longer be exposing joda objects directly anywhere. There is some weirdness related to the linked issue in that I can't find that whitelist file anywhere in master/7.x. @pgomulka can you take a look? |
@icalvete can you please provide me with more details on how to reproduce this? Is this a script running from a watcher? |
@icalvete also can you confirm if data used here was created in 6 before upgrading to 7? |
This a piece of the script... ` a.timestamp.toInstant().toEpochMilli() This is @timestamp mapping.
You are rigth. The indexes were created by 6. |
@icalvete can you elaborate a bit more on the script? How do you use it? in a watcher? in a search? |
@icalvete in order to debug this issue we're gonna need some more information. |
We fixit.
We cast the @timestamp field to (ZonedDateTime)
Thanks. |
hey @icalvete this is really surprising that it fixed the problem. |
You can reproduce the issue (at least in our environment, with our data) in a scripted metric computed in a query. We have a mapping like this for the index "my_index":
The following query
...returns a list of dates, as expected:
But if we try instead to return a list of epoch values (adding .toInstant().toEpochMilli()):
... then it fails:
If we cast to ZonedDateTime in the map_script:
... then it works as expected and returns the epoch millis array.
Apparently during the map_script the underlying object is being casted to a org.joda.time.DateTime and forcing an explicit cast to a ZonedDateTime fixes the issue. |
The JodaCompatibleZonedDateTime is a compatibility object that unions Joda's DateTime and Java's ZonedDateTime, meant for use in scripts. When it was added, we serialized the JCZDT as a Joda DateTime so that when sending to older nodes they could still read the object. However, on newer nodes, we continued also reading this as a Joda DateTime. This commit changes the read side to form a JCZDT. closes elastic#53586
Thanks for the more detailed reproduction. I've tracked it down and have a fix: #53823. |
The JodaCompatibleZonedDateTime is a compatibility object that unions Joda's DateTime and Java's ZonedDateTime, meant for use in scripts. When it was added, we serialized the JCZDT as a Joda DateTime so that when sending to older nodes they could still read the object. However, on newer nodes, we continued also reading this as a Joda DateTime. This commit changes the read side to form a JCZDT. closes #53586
The JodaCompatibleZonedDateTime is a compatibility object that unions Joda's DateTime and Java's ZonedDateTime, meant for use in scripts. When it was added, we serialized the JCZDT as a Joda DateTime so that when sending to older nodes they could still read the object. However, on newer nodes, we continued also reading this as a Joda DateTime. This commit changes the read side to form a JCZDT. closes #53586
Elasticsearch version (
bin/elasticsearch --version
):7.6.1
Plugins installed: []
JVM version (
java -version
):openjdk 13.0.2 2020-01-14
OS version (
uname -a
if on a Unix-like system):Ubuntu 18.04.3 LTS
Description of the problem including expected versus actual behavior:
I read some info related.
#35913
8264326#diff-7a890307c61fef9c84ca1e75a4ba7639
Am i doing something wrong or is that a bug?
Thanks.
The text was updated successfully, but these errors were encountered: