Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 1.2.22+版本bug,在低负载时仍然会不断创建连接直到maxActive #6318

Open
bgh100 opened this issue Jan 7, 2025 · 3 comments

Comments

@bgh100
Copy link

bgh100 commented Jan 7, 2025

Database Type

any

Database Version

any

Druid Version

1.2.22+

JDK Version

any

Error SQL

none

Testcase Code

import com.alibaba.druid.pool.DruidDataSource
import groovy.sql.Sql

class TestDruid {
    static void main(String[] args) {
        def dataSource = getDataSource()
        def sql = new Sql(dataSource)
        List datas = sql.rows("select 1000")

        sleep(3600000)
    }

    static DruidDataSource getDataSource() {
        DruidDataSource dataSource = new DruidDataSource()
        dataSource.setUrl("xxxxxx")
        dataSource.setUsername("xxxxxx")
        dataSource.setPassword("xxxxxx")
        dataSource.setDriverClassName("xxxxxx")
        dataSource.setInitialSize(10)
        dataSource.setMaxActive(50)
        dataSource.setMinIdle(10)
        dataSource.setMinEvictableIdleTimeMillis(7200000)
        dataSource.setValidationQuery("select 123")
        dataSource.setKeepAlive(true)
        return dataSource
    }
}

会以默认周期2分钟的频率创建新连接:
image

Stacktrace Info

No response

Error Info

2833431#diff-607f3e6b95004336d0b44bf13934c27efcac5ba101094d89a9524095f351ee30L3404

image
1.2.22之前,此处fillCount为负数时,不会进入for循环,不会执行emptySignal()触发创建新连接。

@bgh100 bgh100 changed the title [BUG] 1.2.22版本bug,在低负载时仍然会不断创建连接直到maxActive [BUG] 1.2.22+版本bug,在低负载时仍然会不断创建连接直到maxActive Jan 8, 2025
@ChaimNJ
Copy link

ChaimNJ commented Jan 14, 2025

同样遇到类似问题,低负载时,连接不释放,跟代码发现一直在销毁和创建连接

@AnyuanLuo
Copy link

升级到1.2.22,空载时连接数降不下去,回退到1.2.20就没问题了。发现1.2.22版本一直在新建连接,这个有什么临时规避方法么?

@bgh100
Copy link
Author

bgh100 commented Jan 15, 2025

升级到1.2.22,空载时连接数降不下去,回退到1.2.20就没问题了。发现1.2.22版本一直在新建连接,这个有什么临时规避方法么?

考虑下不要配置minIdle,默认0,就不会触发这个问题。
或者minEvictableIdleTimeMillis配置改小,加速释放空闲连接。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants