Re: memory leak when serializing TRUNCATE in reorderbuffer - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: memory leak when serializing TRUNCATE in reorderbuffer
Date
Msg-id 04cfcf19-1a43-5d85-918d-56a8620377c4@2ndquadrant.com
Whole thread Raw
In response to memory leak when serializing TRUNCATE in reorderbuffer  (Tomas Vondra <tomas.vondra@2ndquadrant.com>)
Responses Re: memory leak when serializing TRUNCATE in reorderbuffer
List pgsql-hackers
On 20/06/2018 21:42, Tomas Vondra wrote:
> So I think we should fix and serialize/restore the OID array, just like 
> we do for tuples, snapshots etc. See the attached fix.

Yes please.

> Another thing we should probably reconsider is where the relids is 
> allocated - the pointer remains valid because we happen to allocate it 
> in TopMemoryContext. It's not that bad because we don't free the other 
> reorderbuffer contexts until the walsender exits anyway, but still.
> 
> So I propose to allocate it in rb->context just like the other bits of 
> data (snapshots, ...). Replacing the palloc() in DecodeTruncate() with 
> something like:
> 
>     MemoryContextAlloc(ctx->reorder->context,
>                        xlrec->nrelids * sizeof(Oid));
> 
> should do the trick.

It's not clear from the code comments which context would be the
appropriate one.

More standard coding style would be to set the current memory context
somewhere, but I suppose the reorderbuffer.c code isn't written that way.

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Fix hints on CREATE PROCEDURE errors
Next
From: Peter Eisentraut
Date:
Subject: unused/redundant foreign key code