]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix memory leak and inefficiency in CREATE DATABASE ... STRATEGY WAL_LOG
authorAndres Freund <andres@anarazel.de>
Wed, 22 Mar 2023 16:26:23 +0000 (09:26 -0700)
committerAndres Freund <andres@anarazel.de>
Wed, 22 Mar 2023 16:26:23 +0000 (09:26 -0700)
commit560bb56c6eba5da7917e67783d46f0d5ca30e89a
tree1636c19449a402440e31ffb111a116395a5c44fd
parenta70e6e430628fe5ee802f47f4b043d33a0d41dda
Fix memory leak and inefficiency in CREATE DATABASE ... STRATEGY WAL_LOG

RelationCopyStorageUsingBuffer() did not free the strategies used to access
the source / target relation. They memory was released at the end of the
transaction, but when using a template database with a lot of relations, the
temporary leak can become big prohibitively big.

RelationCopyStorageUsingBuffer() acquired the buffer for the target relation
with RBM_NORMAL, therefore requiring a read of a block guaranteed to be
zero. Use RBM_ZERO_AND_LOCK instead.

Reviewed-by: Robert Haas <robertmhaas@gmail.com>
Discussion: https://postgr.es/m/20230321070113.o2vqqxogjykwgfrr@awork3.anarazel.de
Backpatch: 15-, where STRATEGY WAL_LOG was introduced
src/backend/storage/buffer/bufmgr.c