Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5df319f

Browse files
committed
Fix memory leak and inefficiency in CREATE DATABASE ... STRATEGY WAL_LOG
RelationCopyStorageUsingBuffer() did not free the strategies used to accessthe source / target relation. They memory was released at the end of thetransaction, but when using a template database with a lot of relations, thetemporary leak can become big prohibitively big.RelationCopyStorageUsingBuffer() acquired the buffer for the target relationwith RBM_NORMAL, therefore requiring a read of a block guaranteed to bezero. Use RBM_ZERO_AND_LOCK instead.Reviewed-by: Robert Haas <robertmhaas@gmail.com>Discussion:https://postgr.es/m/20230321070113.o2vqqxogjykwgfrr@awork3.anarazel.deBackpatch: 15-, where STRATEGY WAL_LOG was introduced
1 parentbbc1376 commit5df319f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3833,11 +3833,9 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator,
38333833
LockBuffer(srcBuf,BUFFER_LOCK_SHARE);
38343834
srcPage=BufferGetPage(srcBuf);
38353835

3836-
/* Use P_NEW to extend the destination relation. */
38373836
dstBuf=ReadBufferWithoutRelcache(dstlocator,forkNum,blkno,
3838-
RBM_NORMAL,bstrategy_dst,
3837+
RBM_ZERO_AND_LOCK,bstrategy_dst,
38393838
permanent);
3840-
LockBuffer(dstBuf,BUFFER_LOCK_EXCLUSIVE);
38413839
dstPage=BufferGetPage(dstBuf);
38423840

38433841
START_CRIT_SECTION();
@@ -3855,6 +3853,9 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator,
38553853
UnlockReleaseBuffer(dstBuf);
38563854
UnlockReleaseBuffer(srcBuf);
38573855
}
3856+
3857+
FreeAccessStrategy(bstrategy_src);
3858+
FreeAccessStrategy(bstrategy_dst);
38583859
}
38593860

38603861
/* ---------------------------------------------------------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp