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

Heng Chen commented on HBASE-14654:
-----------------------------------

I think the reason is that.
We submit batch request using ThreadPool, the relates code is in 
{{AsyncProcess.sendMultiAction}},  like below:
{code}
        // run all the runnables
        for (Runnable runnable : runnables) {
          if ((--actionsRemaining == 0) && reuseThread) {
            runnable.run();
          } else {
            try {
              pool.submit(runnable);  //Notice 
            } catch (Throwable t) {
              .....
          }
        }
{code}

And this thread pool was constructed in {{HTable}} 
{code}
 ThreadPoolExecutor pool = new ThreadPoolExecutor(1, maxThreads, keepAliveTime, 
TimeUnit.SECONDS,
        new SynchronousQueue<Runnable>(), 
Threads.newDaemonThreadFactory("htable"));
{code}

We notice that the first param (corePoolSize) is 1.  As ThreadPoolExecutor 
comments said.
{code}
 * When a new task is submitted in method {@link #execute(Runnable)},
 * and fewer than corePoolSize threads are running, a new thread is
 * created to handle the request, even if other worker threads are
 * idle.  If there are more than corePoolSize but less than
 * maximumPoolSize threads running, a new thread will be created only
 * if the queue is full. 
{code}

As current logic, corePoolSize less than maxPoolSize,  So it will be possible 
to reuse idle thread in ThreadPool.

So we can increase the corePoolSize to make sure every new request will be 
handled by a new thread.




> Reenable TestMultiParallel#testActiveThreadsCount
> -------------------------------------------------
>
>                 Key: HBASE-14654
>                 URL: https://issues.apache.org/jira/browse/HBASE-14654
>             Project: HBase
>          Issue Type: Bug
>            Reporter: Heng Chen
>
> It was disabled in HBASE-14642,  this issue should reenable it.



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

Reply via email to