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

Asked

Viewed 1,539 times

2

Hey there, guys! Can anyone help me how to fix 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;
    }
}

2 answers

1


It’s not directly 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 according to 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;
    }
}

Of BasicResourcePool available on Git (line 291).

To fix you have two options:

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

    dataSource.setMinPoolSize(2);

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

    dataSource.setInitialPoolSize(101);

More remembering again, this is just one warning, and as the code above it will set the initial value as the minimum value (start = min;) when showing this Warning.

In practice your application will continue to work normally.

Another thing, if you are using spring-boot you can configure the datasource pool by 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
  • Thank you very much, Brow-joe I really did not pay attention to that, I was not explicit, to get that Warning with your tip.

0

It’s just a warning (Warning) that the initial value of the pool size (start) is smaller than the minimum pool size (start 3 < min 10), and so 10 will be used as the starting value (using 10 as start).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.