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

connectionQueue never cleared in ConnectionQueryServicesImpl when lease renewal is disabled/unsupported

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.14.1, 5.1.0
    • None
    • None

    Description

      When we create a new PhoenixConnection, we update connectionQueues in CQSI:

          @Override
          public void addConnection(PhoenixConnection connection) throws SQLException {
              connectionQueues.get(getQueueIndex(connection)).add(new WeakReference<PhoenixConnection>(connection));
              if (returnSequenceValues) {
                  synchronized (connectionCountLock) {
                      connectionCount++;
                  }
              }
          }

      We use connectionQueues to determine what needs lease renewal done.

      However, when the user closes a connection, this datastructure is never cleaned up.

          @Override
          public void removeConnection(PhoenixConnection connection) throws SQLException {
              if (returnSequenceValues) {
                  ConcurrentMap<SequenceKey,Sequence> formerSequenceMap = null;
                  synchronized (connectionCountLock) {
                      if (--connectionCount <= 0) {
                          if (!this.sequenceMap.isEmpty()) {
                              formerSequenceMap = this.sequenceMap;
                              this.sequenceMap = Maps.newConcurrentMap();
                          }
                      }
                      if (connectionCount < 0) {
                          connectionCount = 0;
                      }
                  }
                  // Since we're using the former sequenceMap, we can do this outside
                  // the lock.
                  if (formerSequenceMap != null) {
                      // When there are no more connections, attempt to return any sequences
                      returnAllSequences(formerSequenceMap);
                  }
              } else if (shouldThrottleNumConnections){ //still need to decrement connection count
                  synchronized (connectionCountLock) {
                      if (connectionCount > 0) {
                          --connectionCount;
                      }
                  }
              }
          }

      Running a test now, but seems to be the case on master.

      Attachments

        1. PHOENIX-4809.001.patch
          6 kB
          Josh Elser

        Activity

          People

            elserj Josh Elser
            elserj Josh Elser
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: