Re: Memory leak in RelationBuildRowSecurity

From: Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Memory leak in RelationBuildRowSecurity
Date: 2020-09-25 15:16:40
Message-ID: 3f670fa6-5e81-fbd9-b880-eaa275f15e1c@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 25.09.2020 16:48, Tom Lane wrote:
> Konstantin Knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru> writes:
>> There is memory leak in RelationBuildRowSecurity function - it converts
>> node to expression tree in current memory context:
> Hm ... this smells a whole lot like the issue we fixed recently for
> partition expressions, namely: what the devil are we doing reloading
> these expressions during RelationClearRelation? We should delay
> populating that cache until the value is requested.

Sorry, this stack trace was obtained at 9.6 version of Postgres which
the customer is using.
So may be the problem with cache invalidation is already fixed.
But the memory leak in RelationBuildRowSecurity is still present.
May be it is not so critical if RelationBuildRowSecurity will not be
called many times in the same memory context.
But at least calling pfree for a tree is very strange idea: we should
not do it all or allocate tree in separate memory context.

By the way - it is illustration how "SQL function data" is growing after
each invocation of RelationBuildRowSecurity:

SQL function data: 57344 total in 3 blocks; 53112 free (278 chunks);
4232 used
SQL function data: 289213248 total in 3137 blocks; 3281544 free (217
chunks); 285931704 used
SQL function data: 578434688 total in 6265 blocks; 6581320 free (234
chunks); 571853368 used
SQL function data: 1148488960 total in 12520 blocks; 4793680 free (17
chunks); 1143695280 used
SQL function data: 2288597504 total in 25030 blocks; 1222064 free (221
chunks); 2287375440 used

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2020-09-25 15:38:01 Re: BUG #16636: Upper case issue in JSONB type
Previous Message Max Vikharev 2020-09-25 13:53:55 Re: BUG #16620: Autovacuum does not process certain databases after migration from postgresql 10