上下文: 我正在使用配置了 C3P0 连接池 (CP) 的 Simba JDBC 驱动程序访问 AWS Athena DB。即使配置了各种 C3P0 微调属性,数据库连接池线程在一段时间后会被重新初始化。请在下面找到它们的列表:
C3P0 Version: c3p0-0.9.5.5 \[built 11-December-2019 22:18:33 -0800; debug? true; trace: 10\]
maxWait: "20"
maxStatements: "10"
maxPoolSize: "20"
minPoolSize: "3"
maxIdleTime: "1800"
preparedStatementCacheSize: "5"
acquireIncrement: "3"
idleConnectionTestPeriod: "30"
initialPoolSize: "3"
testConnectionOnCheckin: "true"
testConnectionOnCheckout: "false"
debugUnreturnedConnectionStackTraces: "true"
应用程序部署在 2 个具有多个 (>1) 个工作线程的工作线程上。
问题与疑问:
initialPoolSize
根本不起作用。池大小最多为每个工作线程 1 个连接。日志示例 1:来自 1 个工作线程的示例日志(不一定针对同一数据库连接池线程):
[2023-10-22 12:01:54.067] 警告尝试使用附加属性覆盖属性initialPoolSize。继续使用initialPoolSize = 3。
[2023-10-22 12:01:54.235] 信息初始化 c3p0 池... com.mchange.v2.c3p0.PoolBackedDataSource@233ef5fb [connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@39b1da15 [ acquireIncrement -> 3、acquireRetryAttempts -> 30、acquireRetryDelay -> 1000、autoCommitOnClose -> false、automaticTestTable -> null、breakAfterAcquireFailure -> false、checkoutTimeout -> 20000、connectionCustomizerClassName -> null、connectionTesterClassName -> com.mchange.v2.c3p0.impl。 DefaultConnectionTester、contextClassLoaderSource -> 调用者、debugUnreturnedConnectionStackTraces -> true、factoryClassLocation -> null、forceIgnoreUnresolvedTransactions -> false、forceSynchronousCheckins -> false、identityToken -> rvmyeoazo7l0pbm9pc6k|4201cfe6、idleConnectionTestPeriod -> 30、initialPoolSize -> 3、maxAdministrative任务时间 -> 0, maxConnectionAge -> 0,maxIdleTime -> 1800,maxIdleTimeExcessConnections -> 0,maxPoolSize -> 20,maxStatements -> 10,maxStatementsPerConnection -> 5,minPoolSize -> 3,nestedDataSource -> StandardDataSource:
[2023-10-22 12:01:55.788] 调试获取测试 -- 池大小:1;目标池大小:6;想要的目标? 4
[2023-10-22 12:01:55.783] 调试等待可用():
[2023-10-22 12:01:56.460] DEBUG 结果集已打开,现在有 1 个处于活动状态 [2023-10-22 12:01:56.595] DEBUG 关闭 1 个结果集
日志示例 2:问题 2 中多个 CP 对象的日志:
[2023-10-22 07:52:49.552] DEBUG com.mchange.v2.resourcepool.BasicResourcePool [C3P0PooledConnectionPoolManager[identityToken->rvn2r2aznyqbureaga4x|6c762ebf]-AdminTaskTimer]:翻新空闲资源 - 10 月 22 日星期日 07:52:49世界标准时间2023 [com.mchange.v2.resourcepool.BasicResourcePool@52e8fb44]
[2023-10-22 08:01:04.771] DEBUG com.mchange.v2.resourcepool.BasicResourcePool [C3P0PooledConnectionPoolManager[identityToken->rvn2r2aznyqbureaga4x|26020260]-AdminTaskTimer]:翻新空闲资源 - 10 月 22 日星期日 08:01:0 4 世界标准时间2023 [com.mchange.v2.resourcepool.BasicResourcePool@6383620e]
[2023-10-22 08:13:34.773] DEBUG com.mchange.v2.resourcepool.BasicResourcePool [C3P0PooledConnectionPoolManager[identityToken->rvn2r2aznyqbureaga4x|26020260]-AdminTaskTimer]:翻新空闲资源 - 10 月 22 日星期日 08:13:3 4 世界标准时间2023 [com.mchange.v2.resourcepool.BasicResourcePool@6383620e]
[2023-10-22 09:12:49.578] DEBUG com.mchange.v2.resourcepool.BasicResourcePool [C3P0PooledConnectionPoolManager[identityToken->rvn2r2aznyqbureaga4x|6c762ebf]-AdminTaskTimer]:翻新空闲资源 - 10 月 22 日星期日 09:12:49世界标准时间2023 [com.mchange.v2.resourcepool.BasicResourcePool@52e8fb44]
阅读文档:https://www.mchange.com/projects/c3p0/#initialPoolSize
初始池大小
默认:3
池在启动时将尝试获取的连接数。应介于 minPoolSize 和 maxPoolSize 之间。 [参见“基本池配置”]
它说它将在启动后尝试获取。