public inbox for [email protected]  
help / color / mirror / Atom feed
From: MichaelDBA <[email protected]>
To: James Pang <[email protected]>
Cc: [email protected]
Subject: Re: many sessions wait on LWlock WALWrite suddenly
Date: Fri, 11 Apr 2025 18:43:10 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <CAHgTRffKZ8DvcFJHRpwkBMQZg5XLRbd5yWe+pSGeVRqbqXDsDg@mail.gmail.com>
References: <CAHgTRffKZ8DvcFJHRpwkBMQZg5XLRbd5yWe+pSGeVRqbqXDsDg@mail.gmail.com>

LWLock always shows up in the case where you have too many concurrent
active connections.  Do a select from the pg_stat_activity table where
state in ('idle in transaction','active'); Then count how many CPUs you
have. If the sql query count returned is greater than 2-3 times the
number of CPUs, you probably have a CPU overload problem and your
solution may be to add a connection pooler between the client and the DB
server.  This is all due to the nature of how PG is architected: every
connection is a process, not a thread.

Regards,
Michael Vitale

James Pang wrote on 4/11/2025 10:36 AM:
>    pgv14.8 , during peak time, we suddenly see hundreds of active
> sessions waiting on LWlock  WALWrite at the same time, but we did not
> find any issue on storage .
> any suggestions ?
>
> Thanks,
>
> James


Regards,

Michael Vitale

[email protected] <mailto:[email protected]>

703-600-9343






Attachments:

  [image/jpeg] pgadvanced3.jpg (20.6K, ../[email protected]/3-pgadvanced3.jpg)
  download | view image

view thread (8+ 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]
  Subject: Re: many sessions wait on LWlock WALWrite suddenly
  In-Reply-To: <[email protected]>

* 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