Re: pgsql: Get rid of copy_partition_key

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgsql: Get rid of copy_partition_key
Date: 2017-12-21 21:22:40
Message-ID: CA+TgmoYbpuUUUp2GhYNwWm0qkah39spiU7uOiNXLz20ASfKYoA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

On Thu, Dec 21, 2017 at 12:43 PM, Alvaro Herrera
<alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> Get rid of copy_partition_key
>
> That function currently exists to avoid leaking memory in
> CacheMemoryContext in case of trouble while the partition key is being
> built, but there's a better way: allocate everything in a memcxt that
> goes away if the current (sub)transaction fails, and once the partition
> key is built and no further errors can occur, make the memcxt permanent
> by making it a child of CacheMemoryContext.

I'm not saying this commit is wrong, but it's a weaker form of
protection than we had before. For instance, suppose that while
building the partition key we do a bunch of random palloc's that are
only used transiently when constructing the key. In the old coding,
those go into the temp context and get blown up immediately; only what
we copy to the new context ends up there. In the new way, they stick
around for as long as the relcache entry does.

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

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2017-12-21 21:36:57 Re: pgsql: Get rid of copy_partition_key
Previous Message Robert Haas 2017-12-21 18:21:36 pgsql: Adjust assertion in GetCurrentCommandId.

Browse pgsql-hackers by date

  From Date Subject
Next Message Joshua D. Drake 2017-12-21 21:24:44 Finalizing logical replication limitations as well as potential features
Previous Message Raúl Marín Rodríguez 2017-12-21 19:33:33 Re: [HACKERS] pow support for pgbench