Skip to content

Fix bug in faster interval rounding#56433

Merged
nik9000 merged 4 commits intoelastic:masterfrom
nik9000:interval_rounding_fast_bug
May 8, 2020
Merged

Fix bug in faster interval rounding#56433
nik9000 merged 4 commits intoelastic:masterfrom
nik9000:interval_rounding_fast_bug

Conversation

@nik9000
Copy link
Copy Markdown
Member

@nik9000 nik9000 commented May 8, 2020

This fixes a bug in the interval rounding and two test bugs that showed
up when I ran 1000s of iterations of the tests. The bug was that we
could end up with duplicate transitions if we only needed the last
transition from the list of fully defined transitions and the
transitions overlapped with the rules. This happens. Its ok. We had
defence against that if we needed more than one transition but forgot it
in this case. Now we have it and assertions to make sure we catch any
similar mistakes.

One test bug had to do with the randomized test calling
round(round(min)) because sometimes the first round call will return
a time less than min. Specifically if min is near daylight savings
time. Anyway, this change fixes it by building an extra-wide prepared
rounding just in case.

The other test bug came up when adding a test for the real bug, namely
that assertRoundingAtOffset made an assertion that wasn't true if the
time to round ended up being in an overlap. This just drops that
assertion. We have similar assertions in cases where we know what kind
of offsets we're working with in other tests.

Closes #56400

This fixes a bug in the interval rounding and two test bugs that showed
up when I ran 1000s of iterations of the tests. The bug was that we
could end up with duplicate transitions if we only needed the last
transition from the list of fully defined transitions and the
transitions overlapped with the rules. This happens. Its ok. We had
defence against that if we needed more than one transition but forgot it
in this case. Now we have it and assertions to make sure we catch any
similar mistakes.

One test bug had to do with the randomized test calling
`round(round(min))` because sometimes the first `round` call will return
a time less than min. Specifically if `min` is near daylight savings
time. Anyway, this change fixes it by building an extra-wide prepared
rounding just in case.

The other test bug came up when adding a test for the real bug, namely
that `assertRoundingAtOffset` made an assertion that wasn't true if the
time to round ended up being in an overlap. This just drops that
assertion. We have similar assertions in cases where we *know* what kind
of offsets we're working with in other tests.

Closes elastic#56400
@elasticmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-analytics-geo (:Analytics/Aggregations)

@elasticmachine elasticmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label May 8, 2020
* Sometimes the rules duplicate the transitions. And
* duplicates confuse us. So we have to skip past them.
*/
minSecond = t.toEpochSecond() + 1;
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the actual bug fix.

@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented May 8, 2020

run elasticsearch-ci/docs

Copy link
Copy Markdown
Member

@not-napoleon not-napoleon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.


public void testLastTransitionOverlapsRules() {
/*
* America/Tijuana's transitions overlap its rules and we have to make
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the phrase "transitions overlap its rules"

@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented May 8, 2020

run elasticsearch-ci/packaging-sample-unix-docker

@nik9000 nik9000 merged commit cb47853 into elastic:master May 8, 2020
nik9000 added a commit to nik9000/elasticsearch that referenced this pull request May 8, 2020
This fixes a bug in the interval rounding and two test bugs that showed
up when I ran 1000s of iterations of the tests. The bug was that we
could end up with duplicate transitions if we only needed the last
transition from the list of fully defined transitions and the
transitions overlapped with the rules. This happens. Its ok. We had
defence against that if we needed more than one transition but forgot it
in this case. Now we have it and assertions to make sure we catch any
similar mistakes.

One test bug had to do with the randomized test calling
`round(round(min))` because sometimes the first `round` call will return
a time less than min. Specifically if `min` is near daylight savings
time. Anyway, this change fixes it by building an extra-wide prepared
rounding just in case.

The other test bug came up when adding a test for the real bug, namely
that `assertRoundingAtOffset` made an assertion that wasn't true if the
time to round ended up being in an overlap. This just drops that
assertion. We have similar assertions in cases where we *know* what kind
of offsets we're working with in other tests.

Closes elastic#56400
@nik9000
Copy link
Copy Markdown
Member Author

nik9000 commented May 8, 2020

I'm backporting this in #56396.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/Aggregations Aggregations >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v7.9.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] testRandomTimeIntervalRounding Failure

4 participants