]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
pg_prewarm: Allow autoprewarm to use more than 1GB to dump blocks.
authorRobert Haas <rhaas@postgresql.org>
Fri, 6 Jun 2025 12:18:26 +0000 (08:18 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 6 Jun 2025 12:18:26 +0000 (08:18 -0400)
Reported-by: Daria Shanina <vilensipkdm@gmail.com>
Author: Daria Shanina <vilensipkdm@gmail.com>
Author: Robert Haas <robertmhaas@gmail.com>
Backpatch-through: 13

contrib/pg_prewarm/autoprewarm.c

index d061731706ac02390c9620e6138fa38b4821d013..bc540e734b52b44ae649eb6a5bacc1a4d37c570e 100644 (file)
@@ -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++)
        {