Skip to content
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

GetWatchResponseTests failing when running jdk11 #38400

Closed
pgomulka opened this issue Feb 5, 2019 · 3 comments · Fixed by #38405
Closed

GetWatchResponseTests failing when running jdk11 #38400

pgomulka opened this issue Feb 5, 2019 · 3 comments · Fixed by #38405
Labels
:Data Management/Watcher >test-failure Triaged test failures from CI

Comments

@pgomulka
Copy link
Contributor

pgomulka commented Feb 5, 2019

The test is passing when running under jdk8 but failing under jdk10 & 11
failing:

./gradlew :x-pack:plugin:core:unitTest -Dtests.seed=20A05DD93A2D55FA -Dtests.class=org.elasticsearch.protocol.xpack.watcher.GetWatchResponseTests -Dtests.method="testFromXContent" -Dtests.security.manager=true -Dtests.locale=ar-SA -Dtests.timezone=America/Kralendijk -Dcompiler.java=11 -Druntime.java=11

working

./gradlew :x-pack:plugin:core:unitTest -Dtests.seed=20A05DD93A2D55FA -Dtests.class=org.elasticsearch.protocol.xpack.watcher.GetWatchResponseTests -Dtests.method="testFromXContent" -Dtests.security.manager=true -Dtests.locale=ar-SA -Dtests.timezone=America/Kralendijk -Dcompiler.java=11 -Druntime.java=8

The resolution of SystemClock was changed from jdk8 - jdk11
The jdk is vauge about this:

This clock is based on the best available system clock. This may use System.currentTimeMillis(), or a higher resolution clock if one is available.

JDK8 SystemClock from Clock.java

  @Override
        public Instant instant() {
            return Instant.ofEpochMilli(millis());
        }

jdk11 SystemClock.instant from Clock.java

 @Override
        public Instant instant() {
            // Take a local copy of offset. offset can be updated concurrently
            // by other threads (even if we haven't made it volatile) so we will
            // work with a local copy.
            long localOffset = offset;
            long adjustment = VM.getNanoTimeAdjustment(localOffset);

            if (adjustment == -1) {
                // -1 is a sentinel value returned by VM.getNanoTimeAdjustment
                // when the offset it is given is too far off the current UTC
                // time. In principle, this should not happen unless the
                // JVM has run for more than ~136 years (not likely) or
                // someone is fiddling with the system time, or the offset is
                // by chance at 1ns in the future (very unlikely).
                // We can easily recover from all these conditions by bringing
                // back the offset in range and retry.

                // bring back the offset in range. We use -1024 to make
                // it more unlikely to hit the 1ns in the future condition.
                localOffset = System.currentTimeMillis()/1000 - 1024;

                // retry
                adjustment = VM.getNanoTimeAdjustment(localOffset);

                if (adjustment == -1) {
                    // Should not happen: we just recomputed a new offset.
                    // It should have fixed the issue.
                    throw new InternalError("Offset " + localOffset + " is not in range");
                } else {
                    // OK - recovery succeeded. Update the offset for the
                    // next call...
                    offset = localOffset;
                }
            }
            return Instant.ofEpochSecond(localOffset, adjustment);
        }
@pgomulka pgomulka added >test-failure Triaged test failures from CI :Data Management/Watcher labels Feb 5, 2019
@pgomulka pgomulka self-assigned this Feb 5, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features

@pgomulka
Copy link
Contributor Author

pgomulka commented Feb 5, 2019

very similar problem to what I did here..
d821da0

@pgomulka pgomulka closed this as completed Feb 5, 2019
@pgomulka pgomulka reopened this Feb 5, 2019
pgomulka added a commit to pgomulka/elasticsearch that referenced this issue Feb 5, 2019
the clock resolution changed from jdk8->jdk10, hence the test is passing
in jdk8 but failing in jdk10. The Watcher's objects are serialised and
deserialised with milliseconds precision, making test to fail in jdk 10
and higher

closes elastic#38400
@javanna
Copy link
Member

javanna commented Feb 5, 2019

can we mute this test if we are not going to merge the corresponding PR straight-away?

pgomulka added a commit that referenced this issue Feb 5, 2019
the clock resolution changed from jdk8->jdk10, hence the test is passing
in jdk8 but failing in jdk10. The Watcher's objects are serialised and
deserialised with milliseconds precision, making test to fail in jdk 10
and higher

closes #38400
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Data Management/Watcher >test-failure Triaged test failures from CI
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants