[CONJ-522] Implement a datasource with pool Created: 2017-09-06 Updated: 2020-12-10 Resolved: 2017-11-07 |
|
| Status: | Closed |
| Project: | MariaDB Connector/J |
| Component/s: | Other |
| Affects Version/s: | None |
| Fix Version/s: | 2.2.0, 1.7.6 |
| Type: | Task | Priority: | Major |
| Reporter: | Diego Dupin | Assignee: | Vladislav Vaintroub |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
Actual implementation of datasource as javadoc indicate correspond to "Basic implementation" Goal is to provide "Connection pooling implementation". Why integrate pooling inside driver ?
Implementation requirement :New DataSource implementation "MariaDbPoolDataSource" will be the pooling implementation, "MariaDbDataSource" won't change, as basic implementation. When using MariaDbPoolDataSources, additional pool configuration properties will be available :
Connection handling :When a new connection is asked to pool, if there is existing connection not used, Connection validation is done then borrowed directly. A dedicated thread will handle new connection creation (one by one) to avoid connection burst. This thread will create connection until maxPoolSize if needed. This only thread will permit to handle "Burst of connection" : Creating connection one after another permit to handle sudden peak of connection, to avoid creating lot of connections immediately and drop them after idle timeout: Exampleconfiguration minPoolSize=2 and maxPoolSize=20 with no activity (only 2 connection in pool) with average query executing in 0.1 milliseconds, a connection average taking 5 milliseconds Connection close:On connection closing, borrowed connection state will be reset, then give back to pool.
Idle timeout Threadif option minPoolSize is set and different than maxPoolSize, an additional thread will periodically close idle connections not used after "maxIdleTime", keeping a minumum number of connection to satisfy "minPoolSize". The idle connections in pool will be validated (COM_PING) if last use time approach @@wait_timeout value. Connection performance boost.When creating a connection, java driver need to execute 1 or 2 additional query after socket initialisation / ssl initialisation. futur possible evolution :
|
| Comments |
| Comment by Vladislav Vaintroub [ 2017-09-08 ] | |||
|
Is it possible to implement it on the lowest level, java.sql.Connection (assuming new URL parameters "&pooled=..", so it is available to people desiring without need of data source? | |||
| Comment by Diego Dupin [ 2017-09-11 ] | |||
|
Finally, I tend to agree for the connection level, because this would solve all kinds of client problems: example spark that mostly use jdbc DriverManager, not Datasource :
| |||
| Comment by Diego Dupin [ 2017-10-11 ] | |||
|
changing state to review (already begin yesterday in fact) |