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

Viktor Csomor edited comment on HIVE-25716 at 12/7/21, 10:50 AM:
-----------------------------------------------------------------

The root cause of the failure

Check:
{code}
    runAcidMetricService();
    long now = System.currentTimeMillis();
    long oldDiff = (now - oldStart)/1000;
    long youngDiff = (now - youngStart)/1000;

    long threshold = 1000;
    int intValue = 
Metrics.getOrCreateGauge(MetricsConstants.OLDEST_READY_FOR_CLEANING_AGE).intValue();
    System.err.println("Now: " + now);
    System.err.println("Old start: " + oldStart);
    System.err.println("Young start: " + youngStart);
    System.err.println("Old diff: " + oldDiff);
    System.err.println("Young diff: " + youngDiff);
    System.err.println("Age: " + intValue);

    boolean assertValue = (intValue <= (oldDiff + threshold));
    Assert.assertTrue(assertValue);
{code}

Output
{code}
Now: 1638863282765
Old start: 1638863245187
Young start: 1638863263762
Old diff: 37 (diff 37578)
Young diff: 19 (19003)
Age: 18 (which is calculated and rounded inside the runAcidMetricsService)
{code}

The problem is about rounding the current time to seconds in different systems.
- Test -> System.currentTimeInMillies()
- Db metric -> NOW() / 1000
The above two instants might have differences in time.


was (Author: vcsomor):
The root cause of the failure

Check:
{code}
    runAcidMetricService();
    long now = System.currentTimeMillis();
    long oldDiff = (now - oldStart)/1000;
    long youngDiff = (now - youngStart)/1000;

    long threshold = 1000;
    int intValue = 
Metrics.getOrCreateGauge(MetricsConstants.OLDEST_READY_FOR_CLEANING_AGE).intValue();
    System.err.println("Now: " + now);
    System.err.println("Old start: " + oldStart);
    System.err.println("Young start: " + youngStart);
    System.err.println("Old diff: " + oldDiff);
    System.err.println("Young diff: " + youngDiff);
    System.err.println("Age: " + intValue);

    boolean assertValue = (intValue <= (oldDiff + threshold));
    Assert.assertTrue(assertValue);
{code}

Output
{code}
Now: 1638863282765
Old start: 1638863245187
Young start: 1638863263762
Old diff: 37 (diff 37578)
Young diff: 19 (19003)
Age: 18 (which is calculated and rounded inside the runAcidMetricsService)
{code}


> Fix flaky test TestCompactionMetrics#testOldestReadyForCleaningAge
> ------------------------------------------------------------------
>
>                 Key: HIVE-25716
>                 URL: https://issues.apache.org/jira/browse/HIVE-25716
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 4.0.0
>            Reporter: Karen Coppage
>            Assignee: Viktor Csomor
>            Priority: Major
>              Labels: flaky-test, pull-request-available
>          Time Spent: 1h
>  Remaining Estimate: 0h
>
> Flaky check failed on run #59:
> [http://ci.hive.apache.org/job/hive-flaky-check/467/|http://ci.hive.apache.org/job/hive-flaky-check/467/]
> {code:java}
> java.lang.AssertionError
>       at org.junit.Assert.fail(Assert.java:87)
>       at org.junit.Assert.assertTrue(Assert.java:42)
>       at org.junit.Assert.assertTrue(Assert.java:53)
>       at 
> org.apache.hadoop.hive.ql.txn.compactor.TestCompactionMetrics.testOldestReadyForCleaningAge(TestCompactionMetrics.java:214)
> {code}
> (!) After turning off the test the problematic line is actually 215 in the 
> codebase
> {code}
> Assert.assertTrue(Metrics.getOrCreateGauge(MetricsConstants.OLDEST_READY_FOR_CLEANING_AGE).intValue()
>  >= youngDiff);
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to