无法从PgBouncer打开连接(连接尝试超时) [英] Not able to open connection from PgBouncer (Connection attempt timed out)

查看:246
本文介绍了无法从PgBouncer打开连接(连接尝试超时)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们将PgBouncer用作基于Spring的应用程序的连接池的中间件.在应用程序中,我们使用HikariCP进行应用程序级连接池.

We are using PgBouncer as the middle ware for connection pooling for our spring-based application. Within the application, we are using HikariCP for application-level connection pooling.

我们为HikariCP设置的maxLifeTime值等于一小时,而idleTimeOut的值设置为30秒.

We have set maxLifeTime value equal to one hour for HikariCP and idleTimeOut is set to 30 seconds.

我观察到,在长时间的闲置时间后,应用收到请求时,我们会收到此错误消息:

I have observed that we are getting this error when app get a request after a long idle time:

Caused by: org.postgresql.util.PSQLException: Connection attempt timed out. at 
org.postgresql.Driver$ConnectThread.getResult(Driver.java:376) at
org.postgresql.Driver.connect(Driver.java:288) at
java.sql.DriverManager.getConnection(DriverManager.java:664) at
java.sql.DriverManager.getConnection(DriverManager.java:247) at
org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:88) at
org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:71) at
com.zaxxer.hikari.pool.HikariPool.addConnection(HikariPool.java:398) at
com.zaxxer.hikari.pool.HikariPool.lambda$addBagItem$2(HikariPool.java:309) at 

推荐答案

仅选择一个连接池 PGBouncer/HikariCP

考虑使用 Postgres安装前的PGBouncer或任何库作为您的语言,该语言可以自己处理可重用的连接.说,对于Clojure,HikariCP将是一个不错的选择

Consider using either PGBouncer in front your Postgres installation or any library for your language that deals with reusable connections by its own. Say, for Clojure, HikariCP would be a good choice

请注意,有一个 Hikari支持PGBouncer的未解决问题

每个应用程序都使用hiPariCp,其maxPool为10,我有约10个应用程序在使用它.我前面有一个PgPool,但似乎并没有那么多地使用连接.似乎每个应用程序实例都试图一直保持它自己的池活动,从而使PgPool变得毫无用处.

Each app is using hikariCp with a maxPool of 10 and I have ~10 apps using it. I have a PgPool in front but it doesn't seem to be reusing connection that much. It seems like each app instance is trying to maintain it's own pool alive all the time making PgPool useless.

这篇关于无法从PgBouncer打开连接(连接尝试超时)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆