Re: BUG #14936: Huge backend memory usage during schema dump of database with many views

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: maxim(dot)boguk(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #14936: Huge backend memory usage during schema dump of database with many views
Date: 2017-11-29 14:48:06
Message-ID: 29532.1511966886@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

maxim(dot)boguk(at)gmail(dot)com writes:
> I got off-list report of the following issue:
> server used all memory and crash with OOM during pg_dump of the database
> with many schemes and views.
> After removing all extra stuff problem can be show with simple run the
> following query on the database:
> select (CASE WHEN pg_has_role(c.relowner, 'USAGE'::text) THEN
> pg_get_viewdef(c.oid) ELSE NULL::text END) as view_src from pg_class c where
> (c.relkind = 'v'::"char");

Hm. It's certainly no surprise if pg_get_viewdef eats memory, but why
wouldn't it get reclaimed at the end of each tuple cycle?

Also: I don't think the above query is very representative of what
pg_dump actually does; AFAIR it pulls view definitions one at a time,
not all at once.

That leads me to guess that what's going on is relcache bloat, since
relcache entries would persist across queries. There's no mechanism
for limiting the number of entries in that cache.

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2017-11-29 15:36:11 Re: BUG in 10.1 - dsa_area could not attach to a segment that has been freed
Previous Message Alexander Voytsekhovskyy 2017-11-29 14:32:19 Re: BUG in 10.1 - dsa_area could not attach to a segment that has been freed