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

Mubarak Seyed commented on HBASE-4893:
--------------------------------------

HConnectionManager.deleteStaleConnection() is part of 0.92 but i would like to 
fix it in 0.90.5. Can we back-port deleteStaleConnection() to 0.90.5?
If i use HConnectionManager.deleteConnection(connection, true) in 0.90.5, it is 
not going to clean-up the stale connection unless connection.isZeroReference() 
== true but it is not as getConnection(Conf) increments the count 

{code}
 public static HConnection getConnection(Configuration conf)
  throws ZooKeeperConnectionException {
    HConnectionKey connectionKey = new HConnectionKey(conf);
    synchronized (HBASE_INSTANCES) {
      ..
      connection.incCount();
      return connection;
    }
  }
{code}

We need the following methods in 0.90.5 

{code}
 public static void deleteStaleConnection(HConnection connection) {
    deleteConnection(connection, true, true);
  }

 private static void deleteConnection(HConnection connection, boolean stopProxy,
      boolean staleConnection) {
    synchronized (HBASE_INSTANCES) {
      for (Entry<HConnectionKey, HConnectionImplementation> connectionEntry : 
HBASE_INSTANCES
          .entrySet()) {
        if (connectionEntry.getValue() == connection) {
          deleteConnection(connectionEntry.getKey(), stopProxy, 
staleConnection);
          break;
        }
      }
    }
  }

  private static void deleteConnection(HConnectionKey connectionKey,
      boolean stopProxy, boolean staleConnection) {
    synchronized (HBASE_INSTANCES) {
      HConnectionImplementation connection = HBASE_INSTANCES
          .get(connectionKey);
      if (connection != null) {
        connection.decCount();
        if (connection.isZeroReference() || staleConnection) {
          HBASE_INSTANCES.remove(connectionKey);
          connection.close(stopProxy);
        } else if (stopProxy) {
          connection.stopProxyOnClose(stopProxy);
        }
      }
    }
  }
{code}

and deleteConnection(conf, stopProxy) needs to call deleteConnection(new 
HConnectionKey(conf), stopProxy, false)

{code}
  public static void deleteConnection(Configuration conf, boolean stopProxy) {
    deleteConnection(new HConnectionKey(conf), stopProxy, false);
  }
{code}
                
> HConnectionImplementation closed-but-not-deleted, need a way to find the 
> state of connection
> --------------------------------------------------------------------------------------------
>
>                 Key: HBASE-4893
>                 URL: https://issues.apache.org/jira/browse/HBASE-4893
>             Project: HBase
>          Issue Type: Bug
>          Components: client
>    Affects Versions: 0.90.1, 0.90.2, 0.90.3, 0.90.4
>         Environment: Linux 2.6, HBase-0.90.1
>            Reporter: Mubarak Seyed
>              Labels: hbase-client
>             Fix For: 0.90.1, 0.90.5
>
>
> In abort() of HConnectionManager$HConnectionImplementation, instance of 
> HConnectionImplementation is marked as this.closed=true.
> There is no way for client application to check the hbase client connection 
> whether it is still opened/good (this.closed=false) or not. We need a method 
> to validate the state of a connection like isClosed().
> {code}
> public boolean isClosed(){
>    return this.closed;
> } 
> {code}
> Once the connection is closed and it should get deleted. Client application 
> still gets a connection from HConnectionManager.getConnection(Configuration) 
> and tries to make a RPC call to RS, since connection is already closed, 
> HConnectionImplementation.getRegionServerWithRetries throws 
> RetriesExhaustedException with error message
> {code}
> Caused by: org.apache.hadoop.hbase.client.RetriesExhaustedException: Trying 
> to contact region server null for region , row 
> 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxx', but failed after 10 attempts.
> Exceptions:
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
> java.io.IOException: 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation@7eab48a7
>  closed
>       at 
> org.apache.hadoop.hbase.client.HConnectionManager$HConnectionImplementation.getRegionServerWithRetries(HConnectionManager.java:1008)
>       at org.apache.hadoop.hbase.client.HTable.get(HTable.java:546)
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to