pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Don't hold ProcArrayLock longer than needed in rare cases
Date: Mon, 23 Nov 2020 21:56:40 +0000
Message-ID: <E1khJpA-0005pi-92@gemulon.postgresql.org> (raw)

Don't hold ProcArrayLock longer than needed in rare cases

While cancelling an autovacuum worker, we hold ProcArrayLock while
formatting a debugging log string.  We can make this shorter by saving
the data we need to produce the message and doing the formatting outside
the locked region.

This isn't terribly critical, as it only occurs pretty rarely: when a
backend runs deadlock detection and it happens to be blocked by a
autovacuum running autovacuum.  Still, there's no need to cause a hiccup
in ProcArrayLock processing, which can be very high-traffic in some
cases.

While at it, rework code so that we only print the string when it is
really going to be used, as suggested by Michael Paquier.

Discussion: https://postgr.es/m/20201118214127.GA3179@alvherre.pgsql
Reviewed-by: Michael Paquier <michael@paquier.xyz>

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/450c8230b1f7eed1e927c44fb710d80502bea1d2

Modified Files
--------------
src/backend/storage/lmgr/proc.c | 35 ++++++++++++++++++++++-------------
1 file changed, 22 insertions(+), 13 deletions(-)



Message-ID: <E1khJpA-0005pi-92@gemulon.postgresql.org>
Permalink:  ../E1khJpA-0005pi-92@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1khJpA-0005pi-92@gemulon.postgresql.org

 · 

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-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Don't hold ProcArrayLock longer than needed in rare cases
  In-Reply-To: <E1khJpA-0005pi-92@gemulon.postgresql.org>
  References: <E1khJpA-0005pi-92@gemulon.postgresql.org>

* 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