Skip to content

Commit e4b8f92

Browse files
committed
pg_prewarm: Allow autoprewarm to use more than 1GB to dump blocks.
Reported-by: Daria Shanina <vilensipkdm@gmail.com> Author: Daria Shanina <vilensipkdm@gmail.com> Author: Robert Haas <robertmhaas@gmail.com> Backpatch-through: 13
1 parent 767d38e commit e4b8f92

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

contrib/pg_prewarm/autoprewarm.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,15 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged)
597597
return 0;
598598
}
599599

600-
block_info_array =
601-
(BlockInfoRecord *) palloc(sizeof(BlockInfoRecord) * NBuffers);
600+
/*
601+
* With sufficiently large shared_buffers, allocation will exceed 1GB, so
602+
* allow for a huge allocation to prevent outright failure.
603+
*
604+
* (In the future, it might be a good idea to redesign this to use a more
605+
* memory-efficient data structure.)
606+
*/
607+
block_info_array = (BlockInfoRecord *)
608+
palloc_extended((sizeof(BlockInfoRecord) * NBuffers), MCXT_ALLOC_HUGE);
602609

603610
for (num_blocks = 0, i = 0; i < NBuffers; i++)
604611
{

0 commit comments

Comments
 (0)