Re: MemoryContextCreate change in PG 11 how should contexts be created

Поиск
Список
Период
Сортировка
От Paul Ramsey
Тема Re: MemoryContextCreate change in PG 11 how should contexts be created
Дата
Msg-id CACowWR33zCgeX4_HdUN3Gsfx31FLwdFkqQaFvvXaMaRtG3aX1w@mail.gmail.com
обсуждение исходный текст
Ответ на MemoryContextCreate change in PG 11 how should contexts be created  ("Regina Obe" <lr@pcorp.us>)
Ответы Re: MemoryContextCreate change in PG 11 how should contexts becreated  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Re: MemoryContextCreate change in PG 11 how should contexts be created  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Tue, Dec 19, 2017 at 12:24 AM, Regina Obe <lr@pcorp.us> wrote:
> On December 13th this change to context creation was committed, which broke
> PostGIS trunk compile against PostgreSQL 11 head.
> https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=9fa6f00b1308d
> d10da4eca2f31ccbfc7b35bb461
>
> Ticketed in PostGIS here:
> https://trac.osgeo.org/postgis/ticket/3946
>
>
> It's been broken for a couple of months
> https://trac.osgeo.org/postgis/ticket/3904  with just core dumping but at
> least it used to compile before December 13th.
>
>
> In going thru the changes I see that MemoryContextCreate was changed to not
> return a context anymore and to take in pointer to the context that should
> be returned among other changes.
>
> I also notice that MemoryContextCreate seems to be rarely used in PostgreSQL
> code in places I would expect and instead AllocSetContextCreateExtended is
> used.
>
> So is the preferred approach to not use MemoryContextCreate in extensions
> and instead for PG < 11 use AllocSetContextCreate and PG >= use
> AllocSetContextCreateExtended?
>
> Sorry if my questions don't make any sense.  Still trying to grapple with
> all these memory context functions and how each is different from the other.
>
> For reference, one of the slices of code we have in place that broke looks
> something like this and we've got I think at least 5 more such instances
> sprinkled  in PostGIS code base.
>
> https://git.osgeo.org/gitea/postgis/postgis/src/branch/svn-trunk/libpgcommon
> /lwgeom_transform.c#L550
>
>
>
>                 MemoryContext PJMemoryContext;
>         POSTGIS_DEBUGF(3, "adding SRID %d with proj4text \"%s\" to query
> cache at index %d", srid, proj_str, PROJ4Cache->PROJ4SRSCacheCount);
>
>         PJMemoryContext = MemoryContextCreate(T_AllocSetContext, 8192,
>                                               &PROJ4SRSCacheContextMethods,
>
> PROJ4Cache->PROJ4SRSCacheContext,
>                                               "PostGIS PROJ4 PJ Memory
> Context");

As Regina noted, we're working in https://trac.osgeo.org/postgis/ticket/3946

Our use of MemoryContextCreate is solely in order to get use
MemoryContextDelete as a callback so that, at the end of a statement,
we can clean up externally allocated memory that we're holding in a
cache. If we had some other callback to use for "the statement is
complete, you can clean up now", we could avoid all this mucking
around with raw MemoryContexts entirely. The MemoryContext trick/hack
is very old, perhaps a callback or hook has been added since then that
we could make use of?


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Aleksandr Parfenov
Дата:
Сообщение: Re: [HACKERS] Flexible configuration for full-text search
Следующее
От: David Steele
Дата:
Сообщение: Re: Basebackups reported as idle