error c3p0 - bad pool size config start 3 min 5. using 5 as start

2

Hello everyone! can someone help me how to solve this error below? I tried a lot and nothing.

Error:

12-Dec-2017 20:27:27.908 INFO [http-nio-8084-exec-6] org.springframework.web.servlet.FrameworkServlet.initServletBean FrameworkServlet 'dispatcher': initialization completed in 1266 ms
12-Dec-2017 20:27:27.923 INFO [http-nio-8084-exec-6] org.apache.catalina.core.StandardContext.reload Reloading Context with name [/Head2Head] is completed
12-Dec-2017 20:27:39.276 INFO [MLog-Init-Reporter] com.mchange.v2.log.MLog. MLog clients using java 1.4+ standard logging.
12-Dec-2017 20:27:39.338 INFO [http-nio-8084-exec-2] com.mchange.v2.c3p0.C3P0Registry. Initializing c3p0-0.9.5.2 [built 08-December-2015 22:06:04 -0800; debug? true; trace: 10]
12-Dec-2017 20:27:39.448 INFO [http-nio-8084-exec-2] com.mchange.v2.c3p0.impl.AbstractPoolBackedDataSource. Initializing c3p0 pool... com.mchange.v2.c3p0.ComboPooledDataSource [ acquireIncrement -> 5, acquireRetryAttempts -> 30, acquireRetryDelay -> 1000, autoCommitOnClose -> false, automaticTestTable -> null, breakAfterAcquireFailure -> false, checkoutTimeout -> 0, connectionCustomizerClassName -> null, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, contextClassLoaderSource -> caller, dataSourceName -> 1hge5tw9sldokl6qlaopl|1f977041, debugUnreturnedConnectionStackTraces -> false, description -> null, driverClass -> com.mysql.jdbc.Driver, extensions -> {}, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, forceSynchronousCheckins -> false, forceUseNamedDriverClass -> false, identityToken -> 1hge5tw9sldokl6qlaopl|1f977041, idleConnectionTestPeriod -> 0, initialPoolSize -> 3, jdbcUrl -> jdbc:mysql://*****************.sa-east-1.rds.amazonaws.com:3306/nadalspringmvc?autoReconnect=true&useSSL=false, maxAdministrativeTaskTime -> 0, maxConnectionAge -> 0, maxIdleTime -> 0, maxIdleTimeExcessConnections -> 0, maxPoolSize -> 100, maxStatements -> 0, maxStatementsPerConnection -> 0, minPoolSize -> 10, numHelperThreads -> 3, preferredTestQuery -> null, privilegeSpawnedThreads -> false, properties -> {user=******, password=******}, propertyCycle -> 0, statementCacheNumDeferredCloseThreads -> 0, testConnectionOnCheckin -> true, testConnectionOnCheckout -> false, unreturnedConnectionTimeout -> 0, userOverrides -> {}, usesTraditionalReflectiveProxies -> false ]
12-Dec-2017 20:27:39.465 WARNING [http-nio-8084-exec-2] com.mchange.v2.resourcepool.BasicResourcePool. Bad pool size config, start 3 < min 10. Using 10 as start.

Code:

package br.com.head2head.dao;

import java.beans.PropertyVetoException;
import javax.sql.DataSource;
import com.mchange.v2.c3p0.ComboPooledDataSource;

public class ConnectionPool {

    private static final String DB_USERNAME = "********";
    private static final String DB_PASSWORD = "********";
    private static final String DB_URL = "jdbc:mysql://********.sa-east-1.rds.amazonaws.com:3306/********?autoReconnect=true&useSSL=false";
    private static final String DB_DRIVER_CLASS = "com.mysql.jdbc.Driver";

    private static ComboPooledDataSource dataSource;

    static {
        try {
            dataSource = new ComboPooledDataSource();
            dataSource.setDriverClass(DB_DRIVER_CLASS);

            dataSource.setJdbcUrl(DB_URL);
            dataSource.setUser(DB_USERNAME);
            dataSource.setPassword(DB_PASSWORD);

            dataSource.setMinPoolSize(100);
            dataSource.setMaxPoolSize(1000);
            dataSource.setAcquireIncrement(5);

        } catch (PropertyVetoException e) {
            e.printStackTrace();
        }
    }

    public static DataSource getDataSource() {
        return dataSource;
    }
}
    
asked by anonymous 13.12.2017 / 00:38

2 answers

1

It's not an error, it's just an alert, apparently you're not setting the initial value for the dataSource.

By default the initial value is 3, and by this excerpt:

if ( start < min ){
    if ( logger.isLoggable( MLevel.WARNING ) )
        logger.log( MLevel.WARNING, "Bad pool size config, start " + start + " < min " + min + ". Using " + min + " as start." );
        start = min;
    }
}

From BasicResourcePool available in Git (line 291) .

To fix you have two options:

  • 1 - Decrease the min pool size to a value less than the initial (default = 3)

    dataSource.setMinPoolSize(2);

  • 2 - Or raise the initial poolSize to a value greater than min

    dataSource.setInitialPoolSize(101);

More remembering again, this is only a warning , and according to the code above it will set the initial value as the minimum value ( start = min; ) when displaying this warning.

In practice your application will continue to function normally.

Another thing, if you are using spring-boot you can set the datasource pool to application.yml :

spring:  
  datasource:
    driverClassName: com.mysql.jdbc.Driver
    url: jdbc:mysql://********.sa-east-1.rds.amazonaws.com:3306/********?autoReconnect=true&useSSL=false
    username: ********
    password: ********
    validationQuery: SELECT 1
  jpa:
    show-sql: false
    hibernate:
      ddl-auto: update
      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy
      enable_lazy_load_no_trans: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.MySQLDialect
        c3p0:
          acquire_increment: 5
          idle_test_period: 3000
          max_size: 1000
          max_statements: 300
          min_size: 100
          timeout: 500
          validate: false
    
13.12.2017 / 11:22
0

It is only a warning that the initial value of the pool size is less than the minimum size of the pool (start 3

13.12.2017 / 11:20