From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Avoid O(N^2) behavior when the standby process releases many loc |
Date: | 2021-10-31 19:32:21 |
Message-ID: | E1mhGZ3-0001Vz-2p@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
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
------
REL_13_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/df238aed1090249a2bcd21e1688a398c6f513dfd
Modified Files
--------------
src/backend/storage/ipc/standby.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-10-31 22:12:58 | pgsql: Doc: improve README files associated with TAP tests. |
Previous Message | Tom Lane | 2021-10-31 16:43:56 | pgsql: plpgsql: report proper line number for errors in variable initia |