From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid O(N^2) behavior when the standby process releases many loc
Date: Sun, 31 Oct 2021 19:32:21 +0000
Message-ID: <E1mhGZ3-0001Vv-1e@gemulon.postgresql.org> (raw)
Avoid O(N^2) behavior when the standby process releases many locks.
When replaying a transaction that held many exclusive locks on the
primary, a standby server's startup process would expend O(N^2)
effort on manipulating the list of locks. This code was fine when
written, but commit 1cff1b95a made repetitive list_delete_first()
calls inefficient, as explained in its commit message. Fix by just
iterating the list normally, and releasing storage only when done.
(This'd be inadequate if we needed to recover from an error occurring
partway through; but we don't.)
Back-patch to v13 where 1cff1b95a came in.
Nathan Bossart
Discussion: https://postgr.es/m/CD2F0E7F-9822-45EC-A411-AE56F14DEA9F@amazon.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/6301c3adabd947394682e37c933b0f3f83353b28
Modified Files
--------------
src/backend/storage/ipc/standby.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
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: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Avoid O(N^2) behavior when the standby process releases many loc
In-Reply-To: <E1mhGZ3-0001Vv-1e@gemulon.postgresql.org>
References: <E1mhGZ3-0001Vv-1e@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