Druid removeabandoned Meaning and use

Source: Internet
Author: User
http://blog.csdn.net/peterwanghao/article/details/40071857 Original Address

removeabandoned Meaning and use formerly known as: Using the Druid Connection pool's timeout recycling mechanism to troubleshoot connection leakage issues

Summarize:

Meaning: Whether to open automatically clean up the leased connection but not return to the thread pool

Role:

1. Put in activeconnections when renting

2.DyestroyTask timing to shut down the connection without putting it back into the connection pool

The Druid Connection pool is used in the project, and the system is abnormal after running for some time:[HTML] View Plain Copy caused by: org.springframework.jdbc.cannotgetjdbcconnectionexception: could  not get jdbc connection; nested exception is  Com.alibaba.druid.pool.getconnectiontimeoutexception: wait millis 60009, active 50                    at  org.springframework.jdbc.datasource.datasourceutils.getconnection (datasourceutils.java:80)                    at  Org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData (jdbcutils.java:280)                     ... 64 more    Caused by: com.alibaba.druid.pool.getconnectiontimeoutexception: wait millis  60000, active 50                   at  Com.alibaba.druid.pool.DruidDataSource.getConnectionInternal (druiddatasource.java:1071)                     at  Com.alibaba.druid.pool.DruidDataSource.getConnectionDirect (druiddatasource.java:898)                     at  Com.alibaba.druid.filter.FilterChainImpl.dataSource_connect (filterchainimpl.java:4544)   
MySQL Database maximum connection number set to 500, use the client to connect normally. The number of connections is not fully occupied.


The reason for the analysis should be that there is a local connection not closed in the program. So how to decide. Use the Druid Connection pool Timeout recycle mechanism to add the following in the configuration:[HTML]View Plain Copy <!--exceeds the time limit to recycle--> <property name= "removeabandoned" value= "true"/> <!--timeout in seconds. 180 seconds = 3 min--> <property name= "removeabandonedtimeout" value= "180"/> <!--output error log when closing abanded connection--> Roperty name= "logabandoned" value= "true"/>
Run the program, when the connection more than 3 minutes will force the recycle, and output stack (note: The stack is the previous use of the connection is new out, so you can confirm that this link use is not very good recycling.
But theoretically using the mybatis,mybatis will be responsible for the connection pool request playback back.

Place the connection in the activeconnections and then destroytask the data off periodically.
[HTML] View Plain Copy 2014-10-13 16:02:28,919 error [com.alibaba.druid.pool.druiddatasource] -  <abandon connection, open stackTrace            at java.lang.thread.getstacktrace (thread.java:1567)             at com.alibaba.druid.pool.druiddatasource.getconnectiondirect (DruidDataSource.java:995)            at  Com.alibaba.druid.filter.FilterChainImpl.dataSource_connect (filterchainimpl.java:4544)             at com.alibaba.druid.filter.stat.statfilter.datasource_getconnection ( statfilter.java:661)            at  Com.alibaba.druid.filter.FilterChainImpl.dataSource_connect (filterchainimpl.java:4540)             at com.alibaba.druid.pool.druiDdatasource.getconnection (druiddatasource.java:919)             at com.alibaba.druid.pool.druiddatasource.getconnection (druiddatasource.java:911)             at com.alibaba.druid.pool.druiddatasource.getconnection ( druiddatasource.java:98)                        at cn.org.xxx.xxx.xxx.paginationinterceptor.intercept ( paginationinterceptor.java:96)                        at org.apache.ibatis.plugin.plugin.invoke (Plugin.java:60)             at com.sun.proxy $Proxy 59.query (unknown source )            at  Org.apache.ibatis.session.defaults.DefaultSqlSession.selectList (Defaultsqlsession.java:108)   
It is clear where the open connection is not closed and has been in possession.

In the Courtyard

This configuration item affects performance (the spin note: The new thread stack), which is only opened when troubleshooting. It is best to shut down when the system is running.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.