public inbox for [email protected]
help / color / mirror / Atom feedFrom: Greg Sabino Mullane <[email protected]>
To: sud <[email protected]>
Cc: Adrian Klaver <[email protected]>
Cc: pgsql-general <[email protected]>
Subject: Re: Question on session timeout
Date: Tue, 1 Oct 2024 08:14:36 -0400
Message-ID: <CAKAnmm+Q2tbpDT7byjorFEkvjjTUGMuvV2iFhfmBJUW476LR2Q@mail.gmail.com> (raw)
In-Reply-To: <CAD=mzVUns_nBPOOiDMxvZgnra+e9Nz7QJqr3r3X6JFMxuUGRZg@mail.gmail.com>
References: <CAD=mzVX5DYUZxt7VE-eB4=6eXTpbG7r6MiR7gD-0K9cctscnYw@mail.gmail.com>
<[email protected]>
<CAD=mzVUns_nBPOOiDMxvZgnra+e9Nz7QJqr3r3X6JFMxuUGRZg@mail.gmail.com>
On Tue, Oct 1, 2024 at 1:57 AM sud <[email protected]> wrote:
> *Where are you getting the ~2000 count from?*
> Seeing this in the "performance insights" dashboard and also its matching
> when I query the count of sessions from pg_stat_activity.
>
So I'm guessing this is perhaps RDS or Aurora? Stating that up front can be
helpful.
> As you described, a long time open transaction with a session state as
> "idle" will be threatening as that will cause locking
>
No, idle is fine, "idle in transaction" is bad. :)
Is it correct to assume the session in pg_stat_activity with very old
> XACT_START are the one which are part of long running
>
<snip rest of question>
You need to look at the "state" column as your primary bit of information.
Second most important is how long something has been in that state, which
you can find with now() - state_change. The best way to learn all of this
is to open a few concurrent sessions in psql and experiment.
> We have max_connections set as 5000.
>
That's quite high. But if you never reach that high, it doesn't matter a
whole lot.
"Database connection" touching ~2000 then coming down till 200. And we see
> uneven spikes in those, it seems to be matching with the pattern , when we
> have some errors occurring during the insert queries which are submitted by
> the Java application to insert the data into the tables.
>
(What sort of errors?) 2000 is high. Clearly, you are not pooling
connections, or not pooling them well. If you are using plain Postgres,
look into setting up pgbouncer. If using something managed (e.g. RDS) look
into their particular pooling solution. Or fix your application-level
pooling.
Cheers,
Greg
view thread (4+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Question on session timeout
In-Reply-To: <CAKAnmm+Q2tbpDT7byjorFEkvjjTUGMuvV2iFhfmBJUW476LR2Q@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox