Uploaded image for project: 'Phoenix'
  1. Phoenix
  2. PHOENIX-901

Ensure ConnectionQueryServices only initialized once

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 3.0.0, 4.0.0
    • None
    • None

    Description

      We should call connectionQueryServices#init in the else block of this code:

          @Override
          protected ConnectionQueryServices getConnectionQueryServices(String url, Properties info) throws SQLException {
              checkClosed();
      
              ConnectionInfo connInfo = ConnectionInfo.create(url);
              ConnectionInfo normalizedConnInfo = connInfo.normalize(getQueryServices().getProps());
              ConnectionQueryServices connectionQueryServices = connectionQueryServicesMap.get(normalizedConnInfo);
              if (connectionQueryServices == null) {
                  if (normalizedConnInfo.isConnectionless()) {
                      connectionQueryServices = new ConnectionlessQueryServicesImpl(getQueryServices());
                  } else {
                      connectionQueryServices = new ConnectionQueryServicesImpl(getQueryServices(), normalizedConnInfo);
                  }
                  connectionQueryServices.init(url, info);
                  ConnectionQueryServices prevValue = connectionQueryServicesMap.putIfAbsent(normalizedConnInfo, connectionQueryServices);
                  if (prevValue != null) {
                      connectionQueryServices = prevValue;
                  }
              }
              return connectionQueryServices;
          }
      

      like this instead:

          @Override
          protected ConnectionQueryServices getConnectionQueryServices(String url, Properties info) throws SQLException {
              checkClosed();
      
              ConnectionInfo connInfo = ConnectionInfo.create(url);
              ConnectionInfo normalizedConnInfo = connInfo.normalize(getQueryServices().getProps());
              ConnectionQueryServices connectionQueryServices = connectionQueryServicesMap.get(normalizedConnInfo);
              if (connectionQueryServices == null) {
                  if (normalizedConnInfo.isConnectionless()) {
                      connectionQueryServices = new ConnectionlessQueryServicesImpl(getQueryServices());
                  } else {
                      connectionQueryServices = new ConnectionQueryServicesImpl(getQueryServices(), normalizedConnInfo);
                  }
                  ConnectionQueryServices prevValue = connectionQueryServicesMap.putIfAbsent(normalizedConnInfo, connectionQueryServices);
                  if (prevValue != null) {
                      connectionQueryServices = prevValue;
                  } else {
                      connectionQueryServices.init(url, info);
                  }
              }
              return connectionQueryServices;
          }
      

      This has the potential to open multiple HConnections, but it's unclear if this causes harm, as the same, original ConnectionQueryService is returned and used.

      Attachments

        1. phoenix_2.patch
          20 kB
          James R. Taylor
        2. phoenix_3.patch
          20 kB
          James R. Taylor
        3. phoenix_4.patch
          3 kB
          James R. Taylor
        4. phoenix.patch
          9 kB
          James R. Taylor

        Activity

          People

            jamestaylor James R. Taylor
            jamestaylor James R. Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: