Git Product home page Git Product logo

Comments (1)

ttddyy avatar ttddyy commented on July 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.