Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-28323

When AbstractRpcClient calls getConnection, the status of conn should be checked

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Not A Problem
    • 2.5.7
    • None
    • Client
    • None

    Description

      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.

      /**
       * 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;
      } 

      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
      @Override
      public boolean isActive() {
        return channel != null && channel.isActive();
      } 

      I am new to HBase, so my understanding may be wrong. Please correct me.

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            cserwen Zhiwen Deng
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: