diff options
author | Robert Haas <rhaas@postgresql.org> | 2025-06-06 08:18:15 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2025-06-06 08:18:15 -0400 |
commit | 4adbaa36ca8b0042ce24be187542e846ad3a7e51 (patch) | |
tree | c340f146ccef3c84200d2062e3f7648066c44d15 | |
parent | 626b439e367d97f84901b12632976be157ddb696 (diff) |
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
-rw-r--r-- | contrib/pg_prewarm/autoprewarm.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/contrib/pg_prewarm/autoprewarm.c b/contrib/pg_prewarm/autoprewarm.c index 31be24fc9c3..65d3ee2e163 100644 --- a/contrib/pg_prewarm/autoprewarm.c +++ b/contrib/pg_prewarm/autoprewarm.c @@ -597,8 +597,15 @@ apw_dump_now(bool is_bgworker, bool dump_unlogged) return 0; } - block_info_array = - (BlockInfoRecord *) palloc(sizeof(BlockInfoRecord) * NBuffers); + /* + * With sufficiently large shared_buffers, allocation will exceed 1GB, so + * allow for a huge allocation to prevent outright failure. + * + * (In the future, it might be a good idea to redesign this to use a more + * memory-efficient data structure.) + */ + block_info_array = (BlockInfoRecord *) + palloc_extended((sizeof(BlockInfoRecord) * NBuffers), MCXT_ALLOC_HUGE); for (num_blocks = 0, i = 0; i < NBuffers; i++) { |