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
Aggregations: date_histogram aggregation DST bug #8339
Comments
I have been fiddling around with this issue and came up with this fix: thanodnl@1cedf3e The existing tests still pass (I only ran the timezone rounding tests though) and the tests I submitted in the patch above also pass. If you are happy with the result feel free to take this solution. If you need me to open a pull request let me know! |
@thanodnl Your fix and tests look good to me.
Please do! (and ping me when you open it so that I don't miss it) |
@jpountz I just opened the pull request, also mentioned your handle there but I do not know if you get alerted for that. So: PING! 😄 |
Hi,
Since it is the time of year where we adjust our clocks from daylight savings time to normal time again a bug in the date histogram struck us.
When we run a date_histogram in a timezone other than UTC you will see some buckets being wrongfully combined. In the first example you see a
date_histogram
aggregate in UTC followed by the same aggregate in CET;UTC query:
UTC result:
CET query:
UTC result:
Points of interest in these queries are the result buckets for key:
1414278000000
. When ran in UTC it give adoc_count
of216
. When ran in CET it has adoc_count
of0
.Further more, you will find a
doc_count
of216
in the CET bucket of1414281600000
(an hour to late). Last to point out is the next CET bucket, it contains the value of422
which is the sum of222
+200
. As you can see these values can be found in the corresponding bucket and the previous bucket in UTC.Attached you will find a patch file adding some basic tests to the
org.elasticsearch.common.rounding
package. Here we test key rounding for theCET
andAmerica/Chicago
timezones on the days of the DST switch.I tried diggin into the issue and found that it has to do with the recalculation of
preTz.getOffset
on the following lines TimeZoneRounding.java:156 and TimeZoneRounding.java:163.Running this step by step on my first CET test case results the first time (line 156) in 7200000 (2 hours) and the second time in 3600000 (1 hour). This difference is causeing
2014-10-26T01:01:01 GMT+0200
to resolve to2014-10-26T02:00:00 GMT+0200
. Explaining why the1414278000000
(2014-10-26T01:01:01 GMT+0200) bucket to be empty, the next bucket containing the contents of this bucket, and the bucket after that a sum of two buckets.0001-Add-tests-for-timezone-problems.patch:
The text was updated successfully, but these errors were encountered: