Re: palloc() too large on pg_buffercache with large shared_buffers

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: palloc() too large on pg_buffercache with large shared_buffers
Date: 2016-09-14 15:32:12
Message-ID: CA+TgmoZss1mrxyFu2ovFAA-Zv=hgWhT30T0ZRFL=Km2XY5Uj6w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 14, 2016 at 12:13 AM, Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)com> wrote:
> It looks to me pg_buffercache tries to allocate more than 1GB using
> palloc(), when shared_buffers is more than 256GB.
>
> # show shared_buffers ;
> shared_buffers
> ----------------
> 280GB
> (1 row)
>
> # SELECT buffers, d.datname, coalesce(c.relname, '???')
> FROM (SELECT count(*) buffers, reldatabase, relfilenode
> FROM pg_buffercache group by reldatabase, relfilenode) b
> LEFT JOIN pg_database d ON d.oid = b.reldatabase
> LEFT JOIN pg_class c ON d.oid = (SELECT oid FROM pg_database
> WHERE datname = current_database())
> AND b.relfilenode = pg_relation_filenode(c.oid)
> ORDER BY buffers desc;
> ERROR: invalid memory alloc request size 1174405120
>
> It is a situation to use MemoryContextAllocHuge(), instead of palloc().
> Also, it may need a back patching?

I guess so. Although it's not very desirable for it to use that much
memory, I suppose if you have a terabyte of shared_buffers you
probably have 4GB of memory on top of that to show what they contain.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-09-14 15:45:59 Re: [BUGS] BUG #14244: wrong suffix for pg_size_pretty()
Previous Message Robert Haas 2016-09-14 15:29:48 Re: Speed up Clog Access by increasing CLOG buffers