[英]Eager Initializing Connection Pool & Custom Timeout Value
I'm using the Tomcat JDBC Connection Pool (which is the Spring Boot default) to manage connections to my PostgreSQL cluster, and I just noticed that the pool is created only when the very first query is made. 我正在使用Tomcat JDBC连接池(这是Spring Boot的默认设置)来管理与PostgreSQL集群的连接,我只是注意到仅在进行第一个查询时才创建该池。 My question is twofold:
我的问题是双重的:
iptables
to drop all traffic directed at the PostgreSQL cluster. iptables
丢弃了所有针对PostgreSQL集群的流量。 This caused the first query to last for about 127 seconds before failing with the message Unable to create initial connections of pool
. Unable to create initial connections of pool
。 127 seconds is way too much. Well, for your first question, I can only think 2 methods: 好吧,对于您的第一个问题,我只能考虑以下两种方法:
For your second question; 关于第二个问题; if you choose second approach for first question, than it'll automatically resolved.
如果您对第一个问题选择第二种方法,它将自动解决。 But you can always set
但是你总是可以设置
spring.datasouce.max-wait spring.datasouce.max-wait
parameter. 参数。 In the Tomcat Pool doc it says
在Tomcat Pool文档中说
(int) The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception. (int)在引发异常之前,池将等待(无可用连接时)连接返回的最大毫秒数。 Default value is 30000 (30 seconds)
默认值为30000(30秒)
but in your case, it's 127 seconds, which is strange.. 但您的情况是127秒,这很奇怪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.