Re: Connections Increasing Slowly

From: "Bee(dot)Lists" <bee(dot)lists(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Submit Postgresql Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Connections Increasing Slowly
Date: 2020-06-23 02:32:56
Message-ID: 889C9020-88AF-4254-B9D2-D515C4298DAD@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


> On Jun 22, 2020, at 10:07 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> Hmm. If the client thinks the server dropped the connection, but the
> server thinks the connection is still live, that smells strongly of
> network-level disconnects. Does the client let the connection sit idle
> for more than a minute or two at a time? If so I'd bet that some firewall
> in between is deciding that the connection is dead and dropping it.
> Again, setting the server's tcp_keepalives_* settings could help fix that,
> by ensuring that the network connection sees some traffic regularly.

The gem says it used something in the connection pool. Then it says the server dropped it. Like I said, I’m not clear who owns the connections or the connection pool, as the pool can be outdated. There’s a check in the gem to check the connection pool for valid connections, over a set amount of time (it’s variable and I can change it, but it does add overhead). I think that default is 60 minutes.

The client (this gem) throws an error. I don’t think any firewall is on this server that I know of.

Note: This error shows up first thing in the morning sometimes. I’ve not had it in about a week now. I have reduced the max_connections to 30, and the connections are now at 4. I have a bunch of queries on the top page (it’s a dashboard) and it just increased from 2 to 4.

I just set the tcp_keepalives_* to around 3, so we’ll see what’s going on. Another page request has connections up to 8:

select datid, datname, numbackends, xact_commit, stats_reset from pg_stat_database where datname in (‘mydatabase')

Cheers, Bee

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message David Harrigan 2020-06-23 08:36:51 Stored Procedure Multiple Result Sets
Previous Message Tom Lane 2020-06-23 02:07:25 Re: Connections Increasing Slowly