pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Max connections reached without max connections reached
Date: Wed, 1 Dec 2021 15:52:01 -0700
Message-ID: <0fba028d-68da-349c-0996-e83f707824b7@gmail.com> (raw)
In-Reply-To: <CAANVwEuh4+s2fJCfAA_8m5Apy+i=MPOLa=iht-jBO6WH4YbMDA@mail.gmail.com>
References: <CAANVwEt-jwj_5axSJ5M9fOJRtW_1iXqBhsnK+Fofc09hhmsZJA@mail.gmail.com>
	<4176160.1637681607@sss.pgh.pa.us>
	<CAANVwEssH43T3qHwk46idFAAeMb4neeOxn+AXjmyQVbirU1=LA@mail.gmail.com>
	<67613.1637709271@sss.pgh.pa.us>
	<CAANVwEstrNjVyN1HKcE6vCZWkuKWCz8sRHqEtC6vDeM0zXYesQ@mail.gmail.com>
	<81460.1637720668@sss.pgh.pa.us>
	<CAANVwEsLCmXCqr5=cH0cnBwpT3Nfwy5u9v41FJCOYfT-mKf2bg@mail.gmail.com>
	<CAFiTN-sYJuxkMyPRqg1jdyAQt4zRDe39ztoS7zq0BANRpGkMUQ@mail.gmail.com>
	<CAFiTN-u7ih7EuPtHyhOGtM+vAb3Bw152zZdU+RVS7k7ven7X+g@mail.gmail.com>
	<CAANVwEtNuL8ZNdeN+8yjjuc5+HP-X_pKq3rz0auBrzNMzXDzTg@mail.gmail.com>
	<CAFiTN-tD4tEdZEAUO1BZ0jdYu_rH9gNG_uViZdHHx1hj0t=h8Q@mail.gmail.com>
	<CAANVwEts8MVyS-RJKCPVAGG+xEJZaxSJraMoVzU4KNt_7YimSQ@mail.gmail.com>
	<CAFiTN-uANPvW5JoQXkt3ep5Jappu3ymuYeqs7yuqJhdkv5Mf5g@mail.gmail.com>
	<CAANVwEuh4+s2fJCfAA_8m5Apy+i=MPOLa=iht-jBO6WH4YbMDA@mail.gmail.com>

On 12/1/21 3:29 PM, James Sewell wrote:
>
>     Looking again into the back trace[1], it appeared that the backend is
>     getting stuck while getting the subtransaction's parent information,
>     and that can only happen if the snapshot is getting marked as
>     overflowed.  So it seems that some of the scripts are using a lot of
>     sub-transaction (> 64) within a transaction and in such case, we can
>     not cache the sub-transaction information and the snapshot will be
>     marked overflowed.  After that, for checking the visibility of any
>     tuple we need to consult the SLRU to get TopMost transaction
>     information and if the subtransaction SLRU cache is full then it will
>     have to do the I/O.  So in this case it appeared that a lot of
>     parallel scans/new connections are trying to read the pg_subtrans and
>     due to limited cache size that is not even able to load the data in
>     the cache and getting frequently blocked.  So I assume that when you
>     say the startup is getting stuck forever, how long did you wait, maybe
>     it is moving but getting stuck again for the next tuple, so to confirm
>     that attach the process with gdb put breakpoint in XidInMVCCSnapshot()
>     and check whether it is hitting that breakpoint again or not.  Also,
>     check whether you are seeing "SubtransControlLock" in
>     pg_stat_activity.  There is one nice blog[2] explaining this issue so
>     you can refer to that as well.
>
>
> Ah. Snap. This makes a lot of sense. The developers have a nasty habit 
> of using LOOP over rows which has never been stamped out. I bet they 
> have applied this to something with a lot of rows.
>
> Is there a way of seeing which statements / backends / processes have 
> greater than 64 stxns? I'd like to monitor this.
>
> - James
>
> ------------------------------------------------------------------------
> The contents of this email are confidential and may be subject to 
> legal or professional privilege and copyright. No representation is 
> made that this email is free of viruses or other defects. If you have 
> received this communication in error, you may not copy or distribute 
> any part of it or otherwise disclose its contents to anyone. Please 
> advise the sender of your incorrect receipt of this correspondence. 
Also be on the look-out for begin trans; begin trans; etc  I read 
Kumar's report as nested transactions.  If your gang is doing a 
transaction per row, they need a kick in the rear.  Anyone not closing 
those needs a pink slip.

view thread (40+ messages)  latest in thread

Message-ID: <0fba028d-68da-349c-0996-e83f707824b7@gmail.com>
Permalink:  ../0fba028d-68da-349c-0996-e83f707824b7@gmail.com/
Also on:    postgresql.org/message-id/0fba028d-68da-349c-0996-e83f707824b7@gmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: robjsargent@gmail.com
  Subject: Re: Max connections reached without max connections reached
  In-Reply-To: <0fba028d-68da-349c-0996-e83f707824b7@gmail.com>
  References: <CAANVwEt-jwj_5axSJ5M9fOJRtW_1iXqBhsnK+Fofc09hhmsZJA@mail.gmail.com> <4176160.1637681607@sss.pgh.pa.us> <CAANVwEssH43T3qHwk46idFAAeMb4neeOxn+AXjmyQVbirU1=LA@mail.gmail.com> <67613.1637709271@sss.pgh.pa.us> <CAANVwEstrNjVyN1HKcE6vCZWkuKWCz8sRHqEtC6vDeM0zXYesQ@mail.gmail.com> <81460.1637720668@sss.pgh.pa.us> <CAANVwEsLCmXCqr5=cH0cnBwpT3Nfwy5u9v41FJCOYfT-mKf2bg@mail.gmail.com> <CAFiTN-sYJuxkMyPRqg1jdyAQt4zRDe39ztoS7zq0BANRpGkMUQ@mail.gmail.com> <CAFiTN-u7ih7EuPtHyhOGtM+vAb3Bw152zZdU+RVS7k7ven7X+g@mail.gmail.com> <CAANVwEtNuL8ZNdeN+8yjjuc5+HP-X_pKq3rz0auBrzNMzXDzTg@mail.gmail.com> <CAFiTN-tD4tEdZEAUO1BZ0jdYu_rH9gNG_uViZdHHx1hj0t=h8Q@mail.gmail.com> <CAANVwEts8MVyS-RJKCPVAGG+xEJZaxSJraMoVzU4KNt_7YimSQ@mail.gmail.com> <CAFiTN-uANPvW5JoQXkt3ep5Jappu3ymuYeqs7yuqJhdkv5Mf5g@mail.gmail.com> <CAANVwEuh4+s2fJCfAA_8m5Apy+i=MPOLa=iht-jBO6WH4YbMDA@mail.gmail.com> <0fba028d-68da-349c-0996-e83f707824b7@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 DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox