Skip to content

Commit 20bdc71

Browse files
committed
Prevent lazy_space_alloc from making requests that exceed MaxAllocSize,
per report from Stefan Kaltenbrunner.
1 parent 80cadb3 commit 20bdc71

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backend/commands/vacuumlazy.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
*
3232
*
3333
* IDENTIFICATION
34-
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.66 2006/02/11 23:31:34 tgl Exp $
34+
* $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.67 2006/03/04 19:09:09 tgl Exp $
3535
*
3636
*-------------------------------------------------------------------------
3737
*/
@@ -48,6 +48,7 @@
4848
#include "storage/freespace.h"
4949
#include "storage/smgr.h"
5050
#include "utils/lsyscache.h"
51+
#include "utils/memutils.h"
5152
#include "utils/pg_rusage.h"
5253

5354

@@ -957,6 +958,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks)
957958

958959
maxtuples = (maintenance_work_mem * 1024L) / sizeof(ItemPointerData);
959960
maxtuples = Min(maxtuples, INT_MAX);
961+
maxtuples = Min(maxtuples, MaxAllocSize / sizeof(ItemPointerData));
960962
/* stay sane if small maintenance_work_mem */
961963
maxtuples = Max(maxtuples, MaxHeapTuplesPerPage);
962964

@@ -966,6 +968,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks)
966968
palloc(maxtuples * sizeof(ItemPointerData));
967969

968970
maxpages = MaxFSMPages;
971+
maxpages = Min(maxpages, MaxAllocSize / sizeof(PageFreeSpaceInfo));
969972
/* No need to allocate more pages than the relation has blocks */
970973
if (relblocks < (BlockNumber) maxpages)
971974
maxpages = (int) relblocks;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy