DruidDataSource中有个Druid-ConnectionPool-Destroy-XX的线程负责释放连接:protected void createAndStartDestroyThread() { destroyTask = new DestroyTask(); if (destroyScheduler != null) { long period = timeBetweenEvictionRunsMillis; if (period <= 0) { period = 1000; } destro...
DruidDataSource的init方法会执行createAndStartDestroyThread;而createAndStartDestroyThread在destroyScheduler不为null的时候会定时(timeBetweenEvictionRunsMillis)调度destroyTask,不过destroyScheduler默认为null;同时它还启动了DestroyConnectionThread DestroyConnectionThread druid-1.2.11-sources.jar!/com/alibaba/druid/pool/...
destroytask.run()中将要回收的连接放入abandonedList集合中 遍历这个集合中的pooledConnection连接,这些连接将被close掉 activeConnectionLock.lock();try{Iterator<DruidPooledConnection>iter=activeConnections.keySet().iterator();// 遍历正在使用的连接for(;iter.hasNext();){DruidPooledConnectionpooledConnection=iter...
keepAliveBetweenTimeMillis:保活判断时间(默认2分钟,1.1.22之后的版本才有) 通过反编译分析源码,发现伴随着应用启动后,druid框架会启动多个处理线程,其中有一个叫做Druid-ConnectionPool-Destroy-*的线程(专门用于回收空闲连接,见图1),经过对比,druid在1.0.22、1.1.10、1.1.22这几个版本的使用配置上以及处理逻辑上会...
StringthreadName="Druid-ConnectionPool-Destroy-"+System.identityHashCode(this); //创建与启动销毁线程 destroyConnectionThread=newDestroyConnectionThread(threadName); destroyConnectionThread.start(); } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10.
TimeUnit.MILLISECONDS);//减少initedLatch的计数后返回initedLatch.countDown();return;}//在没有自定义的时候,就会创建一个单独的销毁者线程StringthreadName="Druid-ConnectionPool-Destroy-"+System.identityHashCode(this);destroyConnectionThread=newDestroyConnectionThread(threadName);destroyConnectionThread.start();...
2016-12-27 14:35:22.773 [Druid-ConnectionPool-Destroy-1821010113] ERROR com.alibaba.druid.pool.DruidDataSource - abandon connection, owner thread: quartzScheduler_Worker-1, connected time nano: 506518587214834, open stackTrace at java.lang.Thread.getStackTrace(Thread.java:1552) ...
Daemon Thread [Abandoned connection cleanup thread] Daemon Thread [Druid-ConnectionPool-Create-1184124073] Daemon Thread [Druid-ConnectionPool-Destroy-1184124073] 步骤: 导入依赖 <!-- 连接池 --> <dependency> <groupId>com.alibaba</groupId>
DestroyConnectionThread druid-1.2.11-sources.jar!/com/alibaba/druid/pool/DruidDataSource.java 代码语言:javascript 复制 publicclassDestroyConnectionThreadextendsThread{publicDestroyConnectionThread(String name){super(name);this.setDaemon(true);}publicvoidrun(){initedLatch.countDown();for(;;){// 从前面开...
线上运行一段时间后会有大量的Druid-ConnectionPool-Create和Druid-ConnectionPool-Destroy线程,占比1:1,约共有9k个线程,大量的线程导致GC比较频繁最终运行的时间长会导致tomcat不响应。不知道是不是dataSource配置的姿势不对,系统会有几十个不同的数据库连接来满足不同人的需求。