JDBC connection pool timeout, container-managed connection pool
After a connection loss on the VPN connection from the Cloud instance to the on-premise custom database, the user recognizes a problem with the connection to that database. In particular, an attempt to require a database connection from the container connection pool timed out. The Pega log reports exceptions from the method ConnectionManagerImpl.getSemaphoreForConnectionPool().
com.pega.pegarules.pub.database.DatabaseException: Unable to obtain connection for database "..."; timeout exceeded while waiting for a connection: code: <none> SQLState: <none> Message: <none>
Steps to Reproduce
- Create a Database definition rule for an external database:
For "How to connect", select "use JDBC URL" and set "Max Connections" to a low value.
- Change "How to connect" on that Database rule from "use JDBC URL" to "use JDBC Connection Pool".
- Use that database in an agent that runs quite often and keeps the connection for a long period of time before returning it.
- Disconnect the database server while the agent is running and then reconnect.
- You might need to repeat these steps for some time before the error scenario is created.
A defect in Pegasystems’ code or rules, specifically the Database definition rule
A clear indication for the problem is the involvement of the method ConnectionManagerImpl.getSemaphoreForConnectionPool(). This method should not be called when a container-managed connection pool is used.
The "How to connect" options "use JDBC URL" and "use JDBC Connection Pool" have different additional attributes. Unfortunately, the attributes for one option are not invalidated when the other option is activated. Therefore, the code in ConnectionManagerImpl sees these artifacts and responds to them. In this case, the value for Max Connections is not zero (as it should be for a container-managed connection pool). The methods that are related to a PRPC internal connection pool are called.
Until the Database rule defect is resolved in a future release, perform the following local-change:
- Change "How to connect" on the Database rule to "use JDBC URL".
- Set "Max Connection" to zero.
- Switch back to "use JDBC Connection Pool".
- Save the Database rule.
- Restart all nodes in your Pega environment.
Published October 10, 2017 - Updated October 8, 2020
Was this useful?
100% found this useful
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.