From 20bdc71369014f4cb1cf04fafbf99862cfbe2504 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 4 Mar 2006 19:09:09 +0000 Subject: [PATCH] Prevent lazy_space_alloc from making requests that exceed MaxAllocSize, per report from Stefan Kaltenbrunner. --- src/backend/commands/vacuumlazy.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 2c1ba51763..5fc251d6c4 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -31,7 +31,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.66 2006/02/11 23:31:34 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.67 2006/03/04 19:09:09 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -48,6 +48,7 @@ #include "storage/freespace.h" #include "storage/smgr.h" #include "utils/lsyscache.h" +#include "utils/memutils.h" #include "utils/pg_rusage.h" @@ -957,6 +958,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks) maxtuples = (maintenance_work_mem * 1024L) / sizeof(ItemPointerData); maxtuples = Min(maxtuples, INT_MAX); + maxtuples = Min(maxtuples, MaxAllocSize / sizeof(ItemPointerData)); /* stay sane if small maintenance_work_mem */ maxtuples = Max(maxtuples, MaxHeapTuplesPerPage); @@ -966,6 +968,7 @@ lazy_space_alloc(LVRelStats *vacrelstats, BlockNumber relblocks) palloc(maxtuples * sizeof(ItemPointerData)); maxpages = MaxFSMPages; + maxpages = Min(maxpages, MaxAllocSize / sizeof(PageFreeSpaceInfo)); /* No need to allocate more pages than the relation has blocks */ if (relblocks < (BlockNumber) maxpages) maxpages = (int) relblocks; -- 2.40.0