[
https://issues.apache.org/jira/browse/DBCP-594?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Shaktisinh Jhala updated DBCP-594:
----------------------------------
Description:
Recently we observed an issue of "This connection has been closed." while
borrowing prepared statement from the pool.
It was trying to create a new PreparedStatement using the pooled connection
object. And the Pooled connection object was already closed due to some reason.
There are two configurations testOnCreate and testOnBorrow ensures that the
connection is validated after create and before borrow. In case of connection
is not valid, DBCP discards such connection from the pool and will not be used
in future. However, in the current scenario, if there is some connection in the
pool which is in closed state, it will throw above error every time when it
will try to create prepareStatement with it. As the actual PgConnection object
is wrapped with the DBCP object the application cannot close the actual DB
connection. So, the DBCP should take care of this error and discard such
connection from the pool in case of this error and should not propagate the
error to the application.
Attached is the exception stack trace for this issue.
was:
Recently we observed an issue of "This connection has been closed." while
borrowing prepared statement from the pool.
It was trying to create a new PreparedStatement using the pooled connection
object. And the Pooled connection object was already closed due to some reason.
There are two configurations testOnCreate and testOnBorrow ensures that the
connection is validated after create and before borrow. In case of connection
is not valid, DBCP discards such connection from the pool and will not be used
in future. However, in the current scenario, if there is some connection in the
pool which is in closed state, it will throw above error every time when it
will try to create prepareStatement with it. As the actual PgConnection object
is wrapped with the DBCP object the application cannot close the connection.
Attached is the exception stack trace for this issue.
> DBCP Does not check the validity of DB connection at the time creating
> preparedStatement
> ----------------------------------------------------------------------------------------
>
> Key: DBCP-594
> URL: https://issues.apache.org/jira/browse/DBCP-594
> Project: Commons DBCP
> Issue Type: Bug
> Affects Versions: 2.9.0
> Environment: OS: CentOS
> DB: PostgreSQL
> Java: openjdk 17.0.8.1 2023-08-24
> Reporter: Shaktisinh Jhala
> Priority: Major
> Attachments: ExceptionStackTrace.txt
>
>
> Recently we observed an issue of "This connection has been closed." while
> borrowing prepared statement from the pool.
> It was trying to create a new PreparedStatement using the pooled connection
> object. And the Pooled connection object was already closed due to some
> reason.
> There are two configurations testOnCreate and testOnBorrow ensures that the
> connection is validated after create and before borrow. In case of connection
> is not valid, DBCP discards such connection from the pool and will not be
> used in future. However, in the current scenario, if there is some connection
> in the pool which is in closed state, it will throw above error every time
> when it will try to create prepareStatement with it. As the actual
> PgConnection object is wrapped with the DBCP object the application cannot
> close the actual DB connection. So, the DBCP should take care of this error
> and discard such connection from the pool in case of this error and should
> not propagate the error to the application.
> Attached is the exception stack trace for this issue.
>
>
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)