pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Avoid O(N^2) behavior when the standby process releases many loc 3+ messages / 1 participants [nested] [flat]
* pgsql: Avoid O(N^2) behavior when the standby process releases many loc @ 2021-10-31 19:32 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2021-10-31 19:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Avoid O(N^2) behavior when the standby process releases many loc @ 2021-10-31 19:32 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2021-10-31 19:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Avoid O(N^2) behavior when the standby process releases many loc @ 2021-10-31 19:32 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2021-10-31 19:32 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/8424dfced790a5c2886ac33f9ce33eb57bf99f09 Modified Files -------------- src/backend/storage/ipc/standby.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2021-10-31 19:32 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2021-10-31 19:32 pgsql: Avoid O(N^2) behavior when the standby process releases many loc Tom Lane <tgl@sss.pgh.pa.us> 2021-10-31 19:32 pgsql: Avoid O(N^2) behavior when the standby process releases many loc Tom Lane <tgl@sss.pgh.pa.us> 2021-10-31 19:32 pgsql: Avoid O(N^2) behavior when the standby process releases many loc Tom Lane <tgl@sss.pgh.pa.us>
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