pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: Laurenz Albe <laurenz.albe@cybertec.at>
Cc: Scott Frazer <sfrazer@couponcabin.com>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Help troubleshooting SubtransControlLock problems
Date: Wed, 7 Mar 2018 13:39:26 -0300
Message-ID: <20180307163926.2xd26uqwefzowxtm@alvherre.pgsql> (raw)
In-Reply-To: <1520437938.2402.10.camel@cybertec.at>

Laurenz Albe wrote:
> Scott Frazer wrote:
> > Hi, we have a Postgres 9.6 setup using replication that has recently started seeing a lot of processes stuck in
> > "SubtransControlLock" as a wait_event on the read-replicas. Like this, only usually about 300-800 of them:
> > 
> > 
> >  179706 | LWLockNamed     | SubtransControlLock

I think you could get in this situation if the range of open
transactions exceeds what fits in the buffers for subtrans.c pages, and
the subtransaction cache overflows (64 entries apiece;
PGPROC_MAX_CACHED_SUBXIDS in src/include/storage/proc.h).  Each page is
2048 transactions (4 bytes per xact, 8192 bytes per page;
SUBTRANS_XACTS_PER_PAGE in src/backend/access/transam/subtrans.c), and
we keep 32 pages (NUM_SUBTRANS_BUFFERS src/include/access/subtrans.h).
So if your oldest transaction is over 64k XIDs old, and you have
transactions with more than 64 subtransactions, you get in trouble.

A simple solution is to increase NUM_SUBTRANS_BUFFERS and recompile.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services




view thread (10+ messages)  latest in thread

Message-ID: <20180307163926.2xd26uqwefzowxtm@alvherre.pgsql>
Permalink:  ../20180307163926.2xd26uqwefzowxtm@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180307163926.2xd26uqwefzowxtm@alvherre.pgsql

 · 

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: alvherre@alvh.no-ip.org, laurenz.albe@cybertec.at, sfrazer@couponcabin.com
  Subject: Re: Help troubleshooting SubtransControlLock problems
  In-Reply-To: <20180307163926.2xd26uqwefzowxtm@alvherre.pgsql>
  References: <1520437938.2402.10.camel@cybertec.at> <20180307163926.2xd26uqwefzowxtm@alvherre.pgsql>

* 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