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

Commitb56fb69

Browse files
committed
Fix excessive memory consumption in the new sort pre-reading code.
LogicalTapeRewind() should not allocate large read buffer, if the tapeis completely empty. The calling code relies on that, for itscalculation of how much memory to allocate for the read buffers. Thatlead to massive overallocation of memory, if maxTapes was high, butonly a few tapes were actually used.Reported by Tomas VondraDiscussion: <7303da46-daf7-9c68-3cc1-9f83235cf37e@2ndquadrant.com>
1 parentbfe2e84 commitb56fb69

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

‎src/backend/utils/sort/logtape.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -778,11 +778,16 @@ LogicalTapeRewind(LogicalTapeSet *lts, int tapenum, bool forWrite)
778778
datablocknum=ltsRewindFrozenIndirectBlock(lts,lt->indirect);
779779
}
780780

781-
/* Allocate a read buffer */
781+
/* Allocate a read buffer(unless the tape is empty)*/
782782
if (lt->buffer)
783783
pfree(lt->buffer);
784-
lt->buffer=palloc(lt->read_buffer_size);
785-
lt->buffer_size=lt->read_buffer_size;
784+
lt->buffer=NULL;
785+
lt->buffer_size=0;
786+
if (datablocknum!=-1L)
787+
{
788+
lt->buffer=palloc(lt->read_buffer_size);
789+
lt->buffer_size=lt->read_buffer_size;
790+
}
786791

787792
/* Read the first block, or reset if tape is empty */
788793
lt->curBlockNumber=0L;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp