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

Commit560bb56

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 parenta70e6e4 commit560bb56

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
@@ -3756,11 +3756,9 @@ RelationCopyStorageUsingBuffer(RelFileNode srcnode,
37563756
LockBuffer(srcBuf,BUFFER_LOCK_SHARE);
37573757
srcPage=BufferGetPage(srcBuf);
37583758

3759-
/* Use P_NEW to extend the destination relation. */
37603759
dstBuf=ReadBufferWithoutRelcache(dstnode,forkNum,blkno,
3761-
RBM_NORMAL,bstrategy_dst,
3760+
RBM_ZERO_AND_LOCK,bstrategy_dst,
37623761
permanent);
3763-
LockBuffer(dstBuf,BUFFER_LOCK_EXCLUSIVE);
37643762
dstPage=BufferGetPage(dstBuf);
37653763

37663764
START_CRIT_SECTION();
@@ -3778,6 +3776,9 @@ RelationCopyStorageUsingBuffer(RelFileNode srcnode,
37783776
UnlockReleaseBuffer(dstBuf);
37793777
UnlockReleaseBuffer(srcBuf);
37803778
}
3779+
3780+
FreeAccessStrategy(bstrategy_src);
3781+
FreeAccessStrategy(bstrategy_dst);
37813782
}
37823783

37833784
/* ---------------------------------------------------------------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp