Uploaded image for project: 'Agroal'
  1. Agroal
  2. AG-186

Connection handler stuck with 'CHECKED_OUT' status if idle validation enabled

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 1.15
    • 1.14
    • pool
    • False
    • False

    Description

      problem in method:

      io.agroal.pool.ConnectionPool#idleValidation 

      if we have idle connection (ConnectionHandler#isIdle return true) then in method 'ConnectionPool#performValidation' if connection is valid (ConnectionHandler#isValid return true) then handler marked with 'CHECKED_OUT' status
      and method ConnectionPool#idleValidation return false
      which is invalid because after it inside method:
      ConnectionPool#getConnection this connection will be skipped 

      while ( idleValidationEnabled && !idleValidation( checkedOutHandler ) ) 

      so it remains stuck with 'CHECKED_OUT' status and will be returned to the pool only after manual flush

      I think it looks like there are missing return statement in ConnectionPool#idleValidation method and correct method should look like this:

      private boolean idleValidation(ConnectionHandler handler) {
          if ( !handler.isIdle( configuration.idleValidationTimeout() ) ) {
              return true;
          }
          if ( handler.setState( CHECKED_OUT, VALIDATION ) ) {
              return performValidation( handler, CHECKED_OUT );
          }
          return false;
      } 

      and it actually worked correctly before refactoring, see this method in 1.12 version:

      private boolean idleValidation(ConnectionHandler handler) {
          if ( !handler.isIdle( configuration.idleValidationTimeout() ) ) {
              return true;
          }
          fireBeforeConnectionValidation( listeners, handler );
          if ( handler.setState( CHECKED_OUT, VALIDATION ) ) {
              if ( configuration.connectionValidator().isValid( handler.getConnection() ) ) {
                  handler.setState( CHECKED_OUT );
                  fireOnConnectionValid( listeners, handler );
                  return true;
              } else {
                  handler.setState( FLUSH );
                  allConnections.remove( handler );
                  metricsRepository.afterConnectionInvalid();
                  fireOnConnectionInvalid( listeners, handler );
                  housekeepingExecutor.execute( new DestroyConnectionTask( handler ) );
              }
          }
          return false;
      } 

      so in 1.12 version method ConnectionPool#idleValidation return true for valid connections. Please fix it in new release.

       

      Attachments

        Activity

          People

            lbarreiro-1 Luis Barreiro
            zelinskiy.victor Victor Zelynskyi (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: