hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Yuan Jiang (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HBASE-11830) TestReplicationThrottler.testThrottling failed on virtual boxes
Date Fri, 08 May 2015 14:40:00 GMT

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

Stephen Yuan Jiang commented on HBASE-11830:
--------------------------------------------

The assert in the tests seems invalid to me.  It assumed that the test would run fast between
2 getNextSleepInterval() calls - less than 1 millisecond.  It just put the bet that the test
machine is fast enough for test to pass.

The formula of "sleepTicks = shouldTillTo - now" is "sleepTicks = this.cycleStartTick + (long)(cycles
* 100) - EnvironmentEdgeManager.currentTime()" - For a 100 cycles, the test expects 10000ms
or 9999ms sleepTicks return - which bet that this.cycleStartTick that set earlier almost equal
to EnvironmentEdgeManager.currentTime(). In a virtual box or a slow machine, this could be
guaranteed.  

[~fenghh] and [~jmspaggi], I think we should relax the assertion - if we go extreme, anything
greater than 0 sleepTicks should be fine (eg. "assertTrue(ticks2 > 0)"); we can also go
some middle ground (eg. "assertTrue(ticks2 > 90% * 10000)").

The following is more details of my analysis:
- the test (I added some comments to highlight the portion that I am talking about): 
{code}
    // throttle bandwidth is 100 and 10 bytes/cycle respectively
    ReplicationThrottler throttler1 = new ReplicationThrottler(100);
    ReplicationThrottler throttler2 = new ReplicationThrottler(10);

    long ticks1 = throttler1.getNextSleepInterval(1000);
=>  long ticks2 = throttler2.getNextSleepInterval(1000);  //<-First Call-> set start
time//

    // 1. the first push size is 1000, though 1000 bytes exceeds 100/10
    //    bandwidthes, but no sleep since it's the first push of current
    //    cycle, amortizing occurs when next push arrives
    assertEquals(0, ticks1);
    assertEquals(0, ticks2);

    throttler1.addPushSize(1000);
    throttler2.addPushSize(1000);

    ticks1 = throttler1.getNextSleepInterval(5);
=>  ticks2 = throttler2.getNextSleepInterval(5);   //<-Second Call-> fetch sleepTicks
based on First Call, expect <1ms between calls //

    // 2. when the second push(5) arrives and throttling(5) is called, the
    //    current cyclePushSize is 1000 bytes, this should make throttler1
    //    sleep 1000/100 = 10 cycles = 1s and make throttler2 sleep 1000/10
    //    = 100 cycles = 10s before the second push occurs -- amortize case
    //    after amortizing, both cycleStartTick and cyclePushSize are reset
    assertTrue(ticks1 == 1000 || ticks1 == 999);
    assertTrue(ticks2 == 10000 || ticks2 == 9999);  //<-ASSERT FIRE->//
{code}

- the code (I removed some code and comments; and I highlight the portion that I want to emphasize):

{code}
  public long getNextSleepInterval(final int size) {
    ...
    long sleepTicks = 0;
    long now = EnvironmentEdgeManager.currentTime();
    if ((double)this.cyclePushSize > bandwidth) {
      double cycles = Math.ceil((double)this.cyclePushSize / bandwidth);
      long shouldTillTo = this.cycleStartTick + (long)(cycles * 100);
      if (shouldTillTo > now) {
=>      sleepTicks = shouldTillTo - now; // <-The test expects that the Second Call
land here->//
      } else {
        this.cycleStartTick = now;
      }
      this.cyclePushSize = 0;
    } else {
      long nextCycleTick = this.cycleStartTick + 100;  //a cycle is 100ms
      if (now >= nextCycleTick) {
=>      this.cycleStartTick = now;  //<--Set by First Call ->//
        this.cyclePushSize = 0;
      } else if (this.cyclePushSize > 0 &&
          ...
      }
    }
    return sleepTicks;
  }
{code}


> TestReplicationThrottler.testThrottling failed on virtual boxes
> ---------------------------------------------------------------
>
>                 Key: HBASE-11830
>                 URL: https://issues.apache.org/jira/browse/HBASE-11830
>             Project: HBase
>          Issue Type: Bug
>          Components: test
>         Environment: kvm with Centos 6.5, openjdk1.7
>            Reporter: Sergey Soldatov
>            Assignee: Stephen Yuan Jiang
>            Priority: Minor
>
> during test runs TestReplicationThrottler.testThrottling sometimes fails with assertion
> testThrottling(org.apache.hadoop.hbase.replication.regionserver.TestReplicationThrottler)
 Time elapsed: 0.229 sec  <<< FAILURE!
> java.lang.AssertionError: null
>         at org.junit.Assert.fail(Assert.java:86)
>         at org.junit.Assert.assertTrue(Assert.java:41)
>         at org.junit.Assert.assertTrue(Assert.java:52)
>         at org.apache.hadoop.hbase.replication.regionserver.TestReplicationThrottler.testThrottling(TestReplicationThrottler.java:69)



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

Mime
View raw message