[CONCPP-2] Implement connection pool Created: 2019-08-07  Updated: 2022-02-02  Resolved: 2022-01-26

Status: Closed
Project: MariaDB Connector/C++
Component/s: General
Affects Version/s: None
Fix Version/s: 1.1.1

Type: New Feature Priority: Critical
Reporter: Ralf Gebhardt Assignee: Lawrin Novitsky
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

PM Planning: RM_CONCPP

 Description   

The MySQL Connector/C++ is providing a connection pool, so MariaDB Connector/C++ should provide the same. The connection pool should be provided via MariaDB Connector/C, see CONC-353

UPDATE: As CONC-353 was closed not to be done it should be reviewed to implement a connection pool directly in the C++ connector.



 Comments   
Comment by Lawrin Novitsky [ 2019-08-08 ]

Can't that really be added in the next version? i.e. not in the 1st beta

Comment by Lawrin Novitsky [ 2022-01-26 ]

Use of pool may be enabled in “classic” connection methods using `pool` property set to true, like:

std::unique_ptr<Connection> conn(DriverManager::getConnection("jdbc:mariadb://localhost:3306/db?user=root&password=someSecretWord&pool=true");

The “new” way is to use DataSource class. MariaDbDataSource class is exposed in the public API:

ds("jdbc:mariadb://localhost:3306/db”);
std::unique_ptr<Connection> conn(ds.getConnection("root", "someSecretWord"));

In this case the pool will be automatically created. In the JDBC, a pool is created if getPooledConnection() is used. These methods are not supported yet, and the pool is created on MariaDbDataSource::getConnection call.
Another extension to JDBC - the pool can be closed with ds.close()
Other connection properties to control the pool:

  • minPoolSize - the minimum number of connections always kept in the pool(maxPoolSize value)
  • maxPoolSize - The maximum number of physical connections that the pool
    can contain(default 8)
  • maxIdleTime - The maximum amount of time in seconds that a connection can
    stay in the pool if not used. This value must always be below
    @wait_timeout value - 45s. Default: 600 in seconds
    (=10 minutes), minimum value is 60 seconds
  • poolValidMinDelay - The period of time after putting of the connection to the pool, during
    which the connection is considered to be good and not validated on return to
    the application.
    0 means validation is done each time the connection is requested
    (default 1000)
Generated at Thu Feb 08 03:07:37 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.