[ 
https://issues.apache.org/jira/browse/CASSANDRA-10139?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14706028#comment-14706028
 ] 

Paulo Motta commented on CASSANDRA-10139:
-----------------------------------------

I ran the test multiple times on Windows, and it passes, so this problem 
happens mostly on CI (intermittently). I found a minor bug in the test, in the 
assignment of the {{nowNanos}} variable:
{code}
nowNanos = Math.max(now, System.nanoTime());
{code}
But {{now}} is actually {{System.currentTimeMillis()}}, so it will always be 
smaller than {{System.naoTime()}}. I changed the assignment to:
{code}
nowNanos = Math.max(nowNanos, System.nanoTime());
{code}
This could be the cause of the failures, if there is a clock synchronization 
service running on WIndows, but I'm not sure of that.

I think this might be caused by difference in the clock resolution on Linux and 
Windows. In the latest test failures there were the following time differences:
* convertedNow - lastConverted = 
[11ms|http://cassci.datastax.com/view/win32/job/cassandra-2.2_utest_win32/77/testReport/org.apache.cassandra.utils/NanoTimeToCurrentTimeMillisTest/testTimestampOrdering/],
 
[6ms|http://cassci.datastax.com/view/win32/job/cassandra-2.2_utest_win32/77/testReport/org.apache.cassandra.utils/NanoTimeToCurrentTimeMillisTest/testTimestampOrdering/]
* convertedNow - now = 
[23ms|http://cassci.datastax.com/view/win32/job/cassandra-2.2_utest_win32/16/testReport/org.apache.cassandra.utils/NanoTimeToCurrentTimeMillisTest/testTimestampOrdering/],
 
[17ms|http://cassci.datastax.com/view/win32/job/cassandra-2.2_utest_win32/53/testReport/org.apache.cassandra.utils/NanoTimeToCurrentTimeMillisTest/testTimestampOrdering/],
 
[19ms|http://cassci.datastax.com/view/win32/job/cassandra-2.2_utest_win32/37/testReport/org.apache.cassandra.utils/NanoTimeToCurrentTimeMillisTest/testTimestampOrdering/],
 
[5ms|http://cassci.datastax.com/view/win32/job/cassandra-2.2_utest_win32/91/testReport/org.apache.cassandra.utils/NanoTimeToCurrentTimeMillisTest/testTimestampOrdering/]

Based on these numbers, I added a tolerance on WIndows of 25ms for 
{{convertedNow - now}} and a tolerance of 15ms for {{convertedNow - 
lastConverted}}. These numbers are more or less accurate with the section 
*Clocks and Timers on Windows* of this [oracle blog 
post|https://blogs.oracle.com/dholmes/entry/inside_the_hotspot_vm_clocks]:

bq. On WIndows, System.currentTimeMillis() is updated at a constant rate 
regardless of how the timer interrupt has been programmed - depending on the 
platform this will either be 10ms or 15ms (this value seems tied to the default 
interrupt period).

The patch is available 
[here|https://github.com/apache/cassandra/compare/cassandra-2.2...pauloricardomg:10139-2.2]
 for review. Unit tests are available below:
* 
[2.2|http://cassci.datastax.com/view/Dev/view/paulomotta/job/pauloricardomg-10139-2.2-testall/lastCompletedBuild/testReport/]
* 
[3.0|http://cassci.datastax.com/view/Dev/view/paulomotta/job/pauloricardomg-10139-3.0-testall/lastCompletedBuild/testReport/]
* 
[trunk|http://cassci.datastax.com/view/Dev/view/paulomotta/job/pauloricardomg-10139-trunk-testall/lastCompletedBuild/testReport/]

Adding [~aweisberg] as reviewer, since he is the original author of the test.


> Windows utest 2.2: NanoTimeToCurrentTimeMillisTest.testTimestampOrdering 
> intermittent failure
> ---------------------------------------------------------------------------------------------
>
>                 Key: CASSANDRA-10139
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-10139
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Joshua McKenzie
>            Assignee: Paulo Motta
>              Labels: Windows
>             Fix For: 2.2.x
>
>
> {noformat}
> now = 1440076083035 convertedNow = 1440076083032 in iteration 8890001
> junit.framework.AssertionFailedError: now = 1440076083035 convertedNow = 
> 1440076083032 in iteration 8890001
>       at 
> org.apache.cassandra.utils.NanoTimeToCurrentTimeMillisTest.testTimestampOrdering(NanoTimeToCurrentTimeMillisTest.java:48)
> {noformat}
> History: 
> [intermittent|http://cassci.datastax.com/view/cassandra-2.2/job/cassandra-2.2_utest_win32/lastCompletedBuild/testReport/org.apache.cassandra.utils/NanoTimeToCurrentTimeMillisTest/testTimestampOrdering/history/]



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to