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

Zhiwen Deng updated HBASE-28323:
--------------------------------
    Description: 
h3. 1. Question

The connection will only be created when it does not exist. Since the conn in 
*connections* are cleaned asynchronously and regularly, it is very likely that 
we will get a closed connection.
{code:java}
/**
 * Get a connection from the pool, or create a new one and add it to the pool. 
Connections to a
 * given host/port are reused.
 */
private T getConnection(ConnectionId remoteId) throws IOException {
  if (failedServers.isFailedServer(remoteId.getAddress())) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Not trying to connect to " + remoteId.getAddress()
        + " this server is in the failed servers list");
    }
    throw new FailedServerException(
      "This server is in the failed servers list: " + remoteId.getAddress());
  }
  T conn;
  synchronized (connections) {
    if (!running) {
      throw new StoppedRpcClientException();
    }
    conn = connections.getOrCreate(remoteId, () -> createConnection(remoteId));
    conn.setLastTouched(EnvironmentEdgeManager.currentTime());
  }
  return conn;
} {code}
h3. 2. Solution
 * 
When getConnection, we should to check whether the conn is active
 * Optimize the impl of isActive and increase the judgment of channel status

{code:java}
@Override
public boolean isActive() {
  return channel != null && channel.isActive();
} {code}
I am new to HBase, so my understanding may be wrong. Please correct me.

 

  was:
h3. 1. Question

The connection will only be created when it does not exist. Since the conn in 
*connections* are cleaned asynchronously and regularly, it is very likely that 
we will get a closed connection.

 

 
{code:java}
/**
 * Get a connection from the pool, or create a new one and add it to the pool. 
Connections to a
 * given host/port are reused.
 */
private T getConnection(ConnectionId remoteId) throws IOException {
  if (failedServers.isFailedServer(remoteId.getAddress())) {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Not trying to connect to " + remoteId.getAddress()
        + " this server is in the failed servers list");
    }
    throw new FailedServerException(
      "This server is in the failed servers list: " + remoteId.getAddress());
  }
  T conn;
  synchronized (connections) {
    if (!running) {
      throw new StoppedRpcClientException();
    }
    conn = connections.getOrCreate(remoteId, () -> createConnection(remoteId));
    conn.setLastTouched(EnvironmentEdgeManager.currentTime());
  }
  return conn;
} {code}
h3. 2. Solution
 * 
When getConnection, we should to check whether the conn is active
 * Optimize the impl of isActive and increase the judgment of channel status

{code:java}
@Override
public boolean isActive() {
  return channel != null && channel.isActive();
} {code}
I am new to HBase, so my understanding may be wrong. Please correct me.

 


> When AbstractRpcClient calls getConnection, the status of conn should be 
> checked
> --------------------------------------------------------------------------------
>
>                 Key: HBASE-28323
>                 URL: https://issues.apache.org/jira/browse/HBASE-28323
>             Project: HBase
>          Issue Type: Bug
>    Affects Versions: 2.5.7
>            Reporter: Zhiwen Deng
>            Priority: Major
>
> h3. 1. Question
> The connection will only be created when it does not exist. Since the conn in 
> *connections* are cleaned asynchronously and regularly, it is very likely 
> that we will get a closed connection.
> {code:java}
> /**
>  * Get a connection from the pool, or create a new one and add it to the 
> pool. Connections to a
>  * given host/port are reused.
>  */
> private T getConnection(ConnectionId remoteId) throws IOException {
>   if (failedServers.isFailedServer(remoteId.getAddress())) {
>     if (LOG.isDebugEnabled()) {
>       LOG.debug("Not trying to connect to " + remoteId.getAddress()
>         + " this server is in the failed servers list");
>     }
>     throw new FailedServerException(
>       "This server is in the failed servers list: " + remoteId.getAddress());
>   }
>   T conn;
>   synchronized (connections) {
>     if (!running) {
>       throw new StoppedRpcClientException();
>     }
>     conn = connections.getOrCreate(remoteId, () -> 
> createConnection(remoteId));
>     conn.setLastTouched(EnvironmentEdgeManager.currentTime());
>   }
>   return conn;
> } {code}
> h3. 2. Solution
>  * 
> When getConnection, we should to check whether the conn is active
>  * Optimize the impl of isActive and increase the judgment of channel status
> {code:java}
> @Override
> public boolean isActive() {
>   return channel != null && channel.isActive();
> } {code}
> I am new to HBase, so my understanding may be wrong. Please correct me.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to