mirror of
https://github.com/mariadb-corporation/mariadb-connector-j.git
synced 2025-07-22 01:28:39 +00:00
cccf87ba7a1553c06ca52b9c676c57025107bdad

Initializing multiple pools in parallel incurred significant lock contention on `poolMap` because this lock was held while any `Pool` was being constructed (which could take several seconds). Because of this, connecting to independent databases in parallel was not possible (Pool creation was serialized), severely limiting overall performance. *Changes* * Add `PoolHolder` to defer creation of `Pool` and act as a lock for each pool key. * Insert a new `PoolHolder` while holding the `poolMap` lock, reducing global thread contention. * Threads looking up the same key will acquire the same `PoolHolder` and that `PoolHolder` will ensure that only one `Pool` is created. Threads looking up unrelated `PoolHolder` will not be blocked by `Pool` creation. * Make registerJxm/unRegisterJmx thread safe. When Pool creation happened in parallel, there were errors in the logs because `Pool` was attempted to be registered more than one. *Testing* This change should have no impact on functionality. Performance should be improved when creating many Pools in parallel. Performance should remain the same when creating `Pool` instances sequentially. * Unit test added to validate that many pools can be created in parallel without issue. * Tested against ~20 real DB servers and saw performance improvement. All connections were created at the same time on separate threads.
MariaDB java connector
MariaDB java connector is a JDBC 4.2 compatible driver, used to connect applications developed in Java to MariaDB and MySQL databases. MariaDB Connector/J is distributed under the LGPL license version 2.1 or later (LGPL-2.1-or-later)
Tracker link https://jira.mariadb.org/projects/CONJ/issues/
Status
Obtaining the driver
For java 8+ :
The driver (jar) can be downloaded from mariadb connector download or maven :
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.5.3</version>
</dependency>
Development snapshot are available on sonatype nexus repository
<repositories>
<repository>
<id>sonatype-nexus-snapshots</id>
<name>Sonatype Nexus Snapshots</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.5.4-SNAPSHOT</version>
</dependency>
</dependencies>
Documentation
For a Getting started guide, API docs, recipes, etc. see the
Contributors
A big thanks to all contributors
Languages
Java
100%