From: Tom Lane Date: Sat, 4 Mar 2006 19:09:23 +0000 (+0000) Subject: Prevent lazy_space_alloc from making requests that exceed MaxAllocSize, X-Git-Tag: REL8_1_4~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53bbc47c2b3c293504a8d66575f47add8683d957;p=postgresql Prevent lazy_space_alloc from making requests that exceed MaxAllocSize, per report from Stefan Kaltenbrunner. --- diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 5237a8c3cd..4691de038b 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.61.2.1 2005/11/22 18:23:08 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/vacuumlazy.c,v 1.61.2.2 2006/03/04 19:09:23 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" @@ -955,6 +956,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); @@ -964,6 +966,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;