[ 
https://issues.apache.org/jira/browse/HBASE-4167?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ted Yu resolved HBASE-4167.
---------------------------

      Resolution: Fixed
    Hadoop Flags: [Reviewed]

> Potential leak of HTable instances when using HTablePool with 
> PoolType.ThreadLocal
> ----------------------------------------------------------------------------------
>
>                 Key: HBASE-4167
>                 URL: https://issues.apache.org/jira/browse/HBASE-4167
>             Project: HBase
>          Issue Type: Bug
>          Components: client
>            Reporter: Gary Helmling
>            Assignee: Karthick Sankarachary
>             Fix For: 0.92.0
>
>         Attachments: HBASE-4167.patch
>
>
> (Initially discussed in HBASE-4150)
> In HTablePool, when obtaining a table:
> {code}
> private HTableInterface findOrCreateTable(String tableName) {
>     HTableInterface table = tables.get(tableName);
>     if (table == null) {
>       table = createHTable(tableName);
>     }
>     return table;
>   }
> {code}
> In the case of {{ThreadLocalPool}}, it seems like there's an exposure here 
> between when the table is created initially and when 
> {{ThreadLocalPool.put()}} is called to set the thread local variable (on 
> {{PooledHTable.close()}}).
> Potential solution described by Karthick Sankarachary:
> For one thing, we might want to clear the tables variable when the 
> {{HTablePool}} is closed (as shown below). For another, we should override 
> ThreadLocalPool#get method so that it removes the resource, otherwise it 
> might end up referencing a HTableInterface that's has been released.
> {code}
> 1 diff --git a/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java 
> b/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java
>       2 index 952a3aa..c198f15 100755
>       3 --- a/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java
>       4 +++ b/src/main/java/org/apache/hadoop/hbase/client/HTablePool.java
>      13 @@ -309,6 +310,7 @@ public class HTablePool implements Closeable {
>      14      for (String tableName : tables.keySet()) {
>      15        closeTablePool(tableName);
>      16      }
>      17 +    this.tables.clear();
>      18    }
> {code}

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to