-
Enhancement
-
Resolution: Done
-
Major
-
5.0.0.Final
ModeShape's DB binary store can be configured in two different ways:
- using a datasource JNDI name
- using a connection url, driver class etc
In (1) the connection managed is handled elsewhere, by the the Datasource.
However in (2), ModeShape will open a new Connection each time using DriverManager.getConnection. This approach can be problematic because it can open a large number of new connections in write-heavy scenarios.
One example of this problem is Oracle throwing the following exception:
aused by: java.lang.RuntimeException: java.sql.SQLException: Listener refused the connection with the following error: ORA-12519, TNS:no appropriate service handler found at org.modeshape.jcr.value.binary.DatabaseBinaryStore.newConnection(DatabaseBinaryStore.java:331) at org.modeshape.jcr.value.binary.DatabaseBinaryStore.dbCall(DatabaseBinaryStore.java:357) at org.modeshape.jcr.value.binary.DatabaseBinaryStore.markAsUnused(DatabaseBinaryStore.java:236) at org.modeshape.jcr.cache.document.WritableSessionCache.lambda$binaryUsageUpdateFunction$38(WritableSessionCache.java:1604) at java.lang.Iterable.forEach(Iterable.java:75) at org.modeshape.jcr.txn.Transactions$BaseTransaction.executeFunctionsUponCommit(Transactions.java:460) at org.modeshape.jcr.txn.Transactions$SimpleTransaction.commit(Transactions.java:503) at org.modeshape.jcr.txn.Transactions$TraceableSimpleTransaction.commit(Transactions.java:551) at org.modeshape.jcr.txn.Transactions$NestableThreadLocalTransaction.commit(Transactions.java:578) at org.modeshape.jcr.cache.document.WritableSessionCache.save(WritableSessionCache.java:747) at org.modeshape.jcr.JcrSession.save(JcrSession.java:1162) ... 33 more Caused by: java.sql.SQLException: Listener refused the connection with the following error: ORA-12519, TNS:no appropriate service handler found at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:489) at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:553) at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:254) at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32) at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:528) at java.sql.DriverManager.getConnection(DriverManager.java:664) at java.sql.DriverManager.getConnection(DriverManager.java:247) at org.modeshape.jcr.value.binary.DatabaseBinaryStore.newConnection(DatabaseBinaryStore.java:328) ... 43 more Caused by: oracle.net.ns.NetException: Listener refused the connection with the following error: ORA-12519, TNS:no appropriate service handler found at oracle.net.ns.NSProtocol.connect(NSProtocol.java:399) at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1140) at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:340) ... 50 more
We should change the code to make sure we're using a connection pool, similarly to the way we're doing for the relational DB provider.