https://bz.apache.org/bugzilla/show_bug.cgi?id=61425
Bug ID: 61425
Summary: all idle connections become '<IDLE> in transaction'
when the 'testWhileIdle' is set to 'true' and
'defaultAutoCommit' is set to 'false'
Product: Tomcat Modules
Version: unspecified
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P2
Component: jdbc-pool
Assignee: [email protected]
Reporter: [email protected]
Target Milestone: ---
In my application, I use spring boot framework, and I choose "Tomcat JDBC Pool"
as my connection pool, what I have configured is as follows.
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/test
spring.datasource.tomcat.driverClassName=org.postgresql.Driver
spring.datasource.tomcat.username=admin
spring.datasource.tomcat.password=admin
spring.datasource.tomcat.initialSize=15
spring.datasource.tomcat.min-idle=15
spring.datasource.tomcat.maxActive=30
spring.datasource.tomcat.max-idle=30
spring.datasource.tomcat.maxWait=300000
spring.datasource.tomcat.timeBetweenEvictionRunsMillis=30000
spring.datasource.tomcat.minEvictableIdleTimeMillis=60000
spring.datasource.tomcat.removeAbandoned=true
spring.datasource.tomcat.removeAbandonedTimeout=900
spring.datasource.tomcat.logAbandoned=true
spring.datasource.tomcat.testWhileIdle=true
spring.datasource.tomcat.validationQuery=SELECT 1
spring.datasource.tomcat.validationInterval=60000
spring.datasource.tomcat.default-auto-commit=false
Then I run my application, 60 seconds later, all the database connections
become into "<IDLE> in transaction".
Why does this happen? I look into the "PooledConnection.java" source code, and
I get the reason.
In the above configuration, I set the "testWhileIdle" to "true", so every
connection in the pool will be tested to see if it is idle, using the specified
SQL "SELECT 1".
After executing the SQL, the connection does not call commit() or rollback().
We know that if the connection is auto committed, this is OK.
But because I set the "defaultAutoCommit" to "false", so the connection will
not be committed automatically, and so the connection will always stay in the
status of "<IDLE> in transaction", and I think this is incorrect.
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]