Comments (1)
datasource-proxy implements the JDBC API. In general, it is the caller's responsibility to perform the necessary clean-up operations when an error is thrown. However, it is a bit tricky in this case.
TL;DR, I believe it is an issue with Tomcat JDBC connection pool, as it is not invalidating its managed connection when an error occurred.
From the caller's perspective (spring JdbcTemplate
/DataSourceUtils#getConnection
), the operation to get a connection ended up as CannotGetJdbcConnectionException
/SQLException
. The caller considers this is a failure to retrieve a connection. This failure does not trigger any cleanup operations on the JDBC API because it does not have a connection object.
At the datasource-proxy level, the ProxyDataSource#getConnection
performs two operations - DataSource#getConnection
and Connection#getTransactionIsolation
. The former succeeded, but the latter failed, so the original ProxyDataSource#getConnection
call fails with SQLException
. At this level, since ProxyDataSource
does not know the underlying datasource(in this case, tomcat jdbc pool), it does not(cannot) do anything. It considers simply the underlying datasource/connection operation has failed and propagates the error to the caller.
At the tomcat jdbc pool level, the initial DataSource#getConnection
operation succeeds and returns a pooled connection. However, the subsequent Connection#getTransactionIsolation
operation fails. When an operation on a managed connection fails, the connection pool should invalidate the connection. Based on your observations, it seems that the pool is not doing so, resulting in the behavior you have described.
From the perspective of the JDBC API, when there is a failure in either DataSource#getConnection
or Connection#getTransactionIsolation
, there is no clean-up action required. It is up to either the caller or the actual JDBC implementor (in this case, tomcat jdbc pool) to respond to the failure.
In my opinion, tomcat jdbc pool needs to react to failures from its managed connections and ensure the stability of the connection pool.
from datasource-proxy.
Related Issues (20)
- Properly call before/after method callback on `ProxyDataSource#getConnection`
- module-info.java HOT 2
- Add `ProxyDataSourceBuilder#buildProxy()`
- Add `ProxyJdbcObject#getProxyConfig`
- No handling of equals method for two connection object HOT 5
- Possibility of intercepting method getConnection() if exception is thrown by original DataSource HOT 2
- equals method of ProxyLogicSupport class not working as expected. HOT 1
- Expose proxy object to method callback
- Reduce transaction Isolation level queries in ProxyDataSource with HikariCP and PostgreSQL HOT 2
- Use monotonic time to measure elapsed time in SystemStopWatch
- Failed to perform getConnection in datasource-proxy 1.10 HOT 3
- Make "AbstractQueryLogEntryCreator#chompIfEndWith" defensive for empty string
- Micrometer support HOT 2
- Got number of type instead null HOT 1
- Add SQL Format Option HOT 1
- Proxying generated keys not working with MS-SQL server data source HOT 4
- Document about Jakarta namespace support HOT 3
- Setting different names for each DataSource used by a routing DataSource HOT 3
- Support Quarkus
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datasource-proxy.