You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hbase.apache.org by "Duo Zhang (JIRA)" <ji...@apache.org> on 2018/09/01 08:29:00 UTC

[jira] [Commented] (HBASE-21136) NPE in MetricsTableSourceImpl.updateFlushTime

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

Duo Zhang commented on HBASE-21136:
-----------------------------------

There is a race, and very easy to reproduce the problem.

{code}
  private void update(AtomicBoolean succ, int round, CyclicBarrier barrier) {
    try {
      for (int i = 0; i < round; i++) {
        String tn = tableName + "-" + i;
        barrier.await(10, TimeUnit.SECONDS);
        rsm.updateFlush(tn, 100, 1000, 500);
      }
    } catch (Exception e) {
      LOG.warn("Failed to update metrics", e);
      succ.set(false);
    }
  }

  @Test
  public void testConcurrentUpdate() throws InterruptedException {
    int threadNumber = 10;
    int round = 100;
    AtomicBoolean succ = new AtomicBoolean(true);
    CyclicBarrier barrier = new CyclicBarrier(threadNumber);
    Thread[] threads = IntStream.range(0, threadNumber)
      .mapToObj(i -> new Thread(() -> update(succ, round, barrier), "Update-Worker-" + i))
      .toArray(Thread[]::new);
    Stream.of(threads).forEach(Thread::start);
    for (Thread t : threads) {
      t.join();
    }
    assertTrue(succ.get());
  }
{code}

Let me prepare a fix also.

> NPE in MetricsTableSourceImpl.updateFlushTime
> ---------------------------------------------
>
>                 Key: HBASE-21136
>                 URL: https://issues.apache.org/jira/browse/HBASE-21136
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Guanghao Zhang
>            Priority: Major
>
> See https://builds.apache.org/job/PreCommit-HBASE-Build/14260/testReport/



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)