Skip to content

TimeZoneRoundingTests#testRoundingRandom fails reproducibly #20833

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
s1monw opened this issue Oct 10, 2016 · 4 comments · Fixed by #21550
Closed

TimeZoneRoundingTests#testRoundingRandom fails reproducibly #20833

s1monw opened this issue Oct 10, 2016 · 4 comments · Fixed by #21550
Assignees
Labels
>bug >test-failure Triaged test failures from CI

Comments

@s1monw
Copy link
Contributor

s1monw commented Oct 10, 2016

 2> REPRODUCE WITH: gradle :core:test -Dtests.seed=17AC5B1BB751F423 -Dtests.class=org.elasticsearch.common.rounding.TimeZoneRoundingTests -Dtests.method="testRoundingRandom" -Dtests.security.manager=true -Dtests.locale=ko -Dtests.timezone=Indian/Comoro
FAILURE 0.69s | TimeZoneRoundingTests.testRoundingRandom <<< FAILURES!
   > Throwable #1: java.lang.AssertionError: dateBetween should round down to roundedDate
   > Expected: Expected: 2024-10-27T00:00:00.000Z [1729987200000] 
   >      but:  was "2024-10-27T00:00:00.000-01:00 [1729990800000]"
   >    at __randomizedtesting.SeedInfo.seed([17AC5B1BB751F423:B8E2E3098394017E]:0)
   >    at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
   >    at org.elasticsearch.common.rounding.TimeZoneRoundingTests.assertInterval(TimeZoneRoundingTests.java:541)
   >    at org.elasticsearch.common.rounding.TimeZoneRoundingTests.testRoundingRandom(TimeZoneRoundingTests.java:195)
   >    at java.lang.Thread.run(Thread.java:745)
  2> NOTE: leaving temporary files on disk at: /Users/simon/projects/elasticsearch/core/build/testrun/test/J0/temp/org.elasticsearch.common.rounding.TimeZoneRoundingTests_17AC5B1BB751F423-001
  2> NOTE: test params are: codec=Asserting(Lucene62): {}, docValues:{}, maxPointsInLeafNode=386, maxMBSortInHeap=5.970189533938357, sim=ClassicSimilarity, locale=ko, timezone=Indian/Comoro
  2> NOTE: Mac OS X 10.11.6 x86_64/Oracle Corporation 1.8.0_66 (64-bit)/cpus=4,threads=1,free=434107792,total=514850816
  2> NOTE: All tests run in this JVM: [TimeZoneRoundingTests]
Completed [1/1] in 2.26s, 1 test, 1 failure <<< FAILURES!
@s1monw s1monw added >bug help wanted adoptme >test-failure Triaged test failures from CI labels Oct 10, 2016
@s1monw
Copy link
Contributor Author

s1monw commented Oct 10, 2016

@cbuescher can you look

@cbuescher cbuescher self-assigned this Oct 10, 2016
@cbuescher cbuescher removed the help wanted adoptme label Oct 10, 2016
@cbuescher
Copy link
Member

cbuescher commented Nov 14, 2016

I couldn't reproduce this on master with the given seed anymore, but going back to some earlier commit I was able get the random parameters that made the test trip in this case. Problem in that test occurs with:

DateTimeUnit.DAY_OF_MONTH
DateTimeZone.forID("Atlantic/Azores")
date = 1729989444634l;

Still need to do some digging what goes wrong here.

@tlrx
Copy link
Member

tlrx commented Nov 14, 2016

@cbuescher Just a side note but I updated JodaTime to v2.9.5 recently and they fixed some bugs like JodaOrg/joda-time#373. Maybe related to this issue.

@cbuescher
Copy link
Member

cbuescher commented Nov 14, 2016

I found the root cause for this. The test error reveals an interesting edge case with DST overlaps (happening usually on DST end, turning back the clock one hour) in combination with rounding to day intervals.

In this particular case (tz: "Atlantic/Azores", dates around the DST transition on e.g. 2000-10-29T01:00:00.000Z) we currently get the overlapping part during the DST transition as a separate rounding interval as illustrated in this table:

date round(date) nextRoundingValue(date)
2000-10-28T22:00:00.000Z  2000-10-28T00:00:00.000Z 2000-10-29T00:00:00.000Z
2000-10-28T23:00:00.000Z  2000-10-28T00:00:00.000Z 2000-10-29T00:00:00.000Z
2000-10-29T00:00:00.000Z  2000-10-29T00:00:00.000Z 2000-10-30T00:00:00.000-01:00
2000-10-29T00:00:00.000-01:00  2000-10-29T00:00:00.000-01:00 2000-10-30T00:00:00.000-01:00
2000-10-29T01:00:00.000-01:00  2000-10-29T00:00:00.000-01:00 2000-10-30T00:00:00.000-01:00
2000-10-29T02:00:00.000-01:00  2000-10-29T00:00:00.000-01:00 2000-10-30T00:00:00.000-01:00

According to https://www.timeanddate.com/time/change/portugal/horta?year=2000 the DST change happenes on Oct-29th at 1am local time, turning back the clock one hour (to offset -01:00). Currently the dates between "2000-10-29T00:00:00.000Z" and "2000-10-29T01:00:00.000Z" all round down to "2000-10-29T00:00:00.000Z" (before the transition) and the dates after but before next midnight round down to "2000-10-29T00:00:00.000-01:00". For a day rounding we would prefer a 25h hour bucket for "2000-10-29" to a one hour + another 24h bucket I guess. I think I have a fix that detects this kind of situation and merges the two intervals.

cbuescher added a commit to cbuescher/elasticsearch that referenced this issue Nov 15, 2016
When using TimeUnitRounding with a DAY_OF_MONTH unit, failing tests in elastic#20833
uncovered an issue when the DST shift happenes just one hour after midnight
local time and sets back the clock to midnight, leading to an overlap.
Previously this would lead to two different rounding values, depending on
whether a date before or after the transition was rounded. This change detects
this special case and correct for it by using the previous rounding date for
both cases.

Closes elastic#20833
cbuescher added a commit that referenced this issue Nov 15, 2016
When using TimeUnitRounding with a DAY_OF_MONTH unit, failing tests in #20833
uncovered an issue when the DST shift happenes just one hour after midnight
local time and sets back the clock to midnight, leading to an overlap.
Previously this would lead to two different rounding values, depending on
whether a date before or after the transition was rounded. This change detects
this special case and correct for it by using the previous rounding date for
both cases.

Closes #20833
cbuescher added a commit that referenced this issue Nov 15, 2016
When using TimeUnitRounding with a DAY_OF_MONTH unit, failing tests in #20833
uncovered an issue when the DST shift happenes just one hour after midnight
local time and sets back the clock to midnight, leading to an overlap.
Previously this would lead to two different rounding values, depending on
whether a date before or after the transition was rounded. This change detects
this special case and correct for it by using the previous rounding date for
both cases.

Closes #20833
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug >test-failure Triaged test failures from CI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants