我有rails和pgBouncer,在reconnect: true
中有database.yml
,但是我一直在控制台中得到它:
ActiveRecord::StatementInvalid: PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly
sidekiq中发生了相同的错误,但web中没有发生,出现此错误后,rails是否应该重新连接?
答案 0 :(得分:0)
这是服务器中配置的超时(我不知道)。因此,它与rails / pgbouncer没有任何关系,实际上reconnect
中的database.yml
标志已不再在rails中使用。
答案 1 :(得分:0)
Maybe it is a solution to set the below configuration parameters of Postgresql.
tcp_keepalives_idle (integer)
Specifies the number of seconds of inactivity after which TCP should send a keepalive message to the client. A value of 0 uses the system default. This parameter is supported only on systems that support TCP_KEEPIDLE or an equivalent socket option, and on Windows; on other systems, it must be zero. In sessions connected via a Unix-domain socket, this parameter is ignored and always reads as zero.
tcp_keepalives_interval (integer)
Specifies the number of seconds after which a TCP keepalive message that is not acknowledged by the client should be retransmitted. A value of 0 uses the system default. This parameter is supported only on systems that support TCP_KEEPINTVL or an equivalent socket option, and on Windows; on other systems, it must be zero. In sessions connected via a Unix-domain socket, this parameter is ignored and always reads as zero.
tcp_keepalives_count (integer)
Specifies the number of TCP keepalives that can be lost before the server's connection to the client is considered dead. A value of 0 uses the system default. This parameter is supported only on systems that support TCP_KEEPCNT or an equivalent socket option; on other systems, it must be zero. In sessions connected via a Unix-domain socket, this parameter is ignored and always reads as zero.