[
https://issues.apache.org/jira/browse/DBCP-597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Xiaotian Bai updated DBCP-597:
------------------------------
Description:
We are running a Java application that uses
*org.apache.commons.dbcp2.datasources.SharedPoolDataSource* to maintain a JDBC
connection pool.
In a recent database failover event, we noticed database validation queries
were not timing out as expected, resulting in the application hanging and
waiting indefinitely for a response from the database.
The validation query and timeout were both explicitly set on the
SharedPoolDataSource instance.
{quote}ds = new SharedPoolDataSource();
ds.setValidationQuery("SELECT 1")
ds.setValidationQueryTimeout(5).
{quote}
Upon diving a bit into the source code, we suspect the issue was caused by this
code:
[https://github.com/apache/commons-dbcp/blob/master/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java#L465]
{quote} conn = pconn.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery(validationQuery);
valid = rset.next();
{quote}
We noticed the _stmt_ statement object does not call setQueryTimeout() and the
validation query seems to be executed with no timeout at all.
Could you confirm that this is indeed a bug, not us missing some fundamental
details? We would greatly appreciate a prompt resolution to this issue, thanks!
was:
We are running a Java application that uses
*org.apache.commons.dbcp2.datasources.SharedPoolDataSource* to maintain a JDBC
connection pool.
In a recent database failover event, we noticed database validation queries
were not timing out as expected, resulting in the application hanging and
waiting indefinitely for a response from the database.
The validation query and timeout were both explicitly set on the
SharedPoolDataSource instance.
{quote}ds = new SharedPoolDataSource();
ds.setValidationQuery("SELECT 1")
ds.setValidationQueryTimeout(5).
{quote}
Upon diving a bit into the source code, we suspect the issue was caused by this
code:
[https://github.com/apache/commons-dbcp/blob/master/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java#L465]
{quote} conn = pconn.getConnection();
stmt = conn.createStatement();
rset = stmt.executeQuery(validationQuery);
valid = rset.next();
{quote}
Looks like the validation query is executed with no timeout at all. However, on
[line
447|https://github.com/apache/commons-dbcp/blob/master/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java#L447]
the timeout is used when the validation query is null.
Could you confirm that this is indeed a bug, not us missing some fundamental
details? We would greatly appreciate a prompt resolution to this issue, thanks!
> Validation query not timing out on connections managed by
> SharedPoolDataSource
> -------------------------------------------------------------------------------
>
> Key: DBCP-597
> URL: https://issues.apache.org/jira/browse/DBCP-597
> Project: Commons DBCP
> Issue Type: Bug
> Affects Versions: 2.9.0
> Reporter: Xiaotian Bai
> Priority: Major
>
> We are running a Java application that uses
> *org.apache.commons.dbcp2.datasources.SharedPoolDataSource* to maintain a
> JDBC connection pool.
> In a recent database failover event, we noticed database validation queries
> were not timing out as expected, resulting in the application hanging and
> waiting indefinitely for a response from the database.
> The validation query and timeout were both explicitly set on the
> SharedPoolDataSource instance.
> {quote}ds = new SharedPoolDataSource();
> ds.setValidationQuery("SELECT 1")
> ds.setValidationQueryTimeout(5).
> {quote}
>
> Upon diving a bit into the source code, we suspect the issue was caused by
> this code:
> [https://github.com/apache/commons-dbcp/blob/master/src/main/java/org/apache/commons/dbcp2/datasources/CPDSConnectionFactory.java#L465]
> {quote} conn = pconn.getConnection();
> stmt = conn.createStatement();
> rset = stmt.executeQuery(validationQuery);
> valid = rset.next();
> {quote}
>
> We noticed the _stmt_ statement object does not call setQueryTimeout() and
> the validation query seems to be executed with no timeout at all.
> Could you confirm that this is indeed a bug, not us missing some fundamental
> details? We would greatly appreciate a prompt resolution to this issue,
> thanks!
--
This message was sent by Atlassian Jira
(v8.20.10#820010)