Re: POC: Sharing record typmods between backends

From: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Dilip Kumar <dilipbalaut(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: POC: Sharing record typmods between backends
Date: 2017-08-24 12:08:08
Message-ID: CAEepm=18WWQs4uX9YSb_LR5nQk1rFd9V+OAjjGhbYbYU2gADLA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 23, 2017 at 11:58 PM, Thomas Munro
<thomas(dot)munro(at)enterprisedb(dot)com> wrote:
> On Wed, Aug 23, 2017 at 5:46 PM, Andres Freund <andres(at)anarazel(dot)de> wrote:
>> Notes for possible followup commits of the dshash API:
>> - nontrivial portions of dsahash are essentially critical sections lest
>> dynamic shared memory is leaked. Should we, short term, introduce
>> actual critical section markers to make that more obvious? Should we,
>> longer term, make this more failsafe / easier to use, by
>> extending/emulating memory contexts for dsa memory?
>
> Hmm. I will look into this.

Yeah, dshash_create() leaks the control object if the later allocation
of the initial hash table array raises an error. I think that should
be fixed -- please see 0001 in the new patch set attached.

The other two places where shared memory is allocated are resize() and
insert_into_bucket(), and both of those seem exception-safe to me: if
dsa_allocate() elogs then nothing is changed, and the code after that
point is no-throw. Am I missing something?

>> - SharedRecordTypmodRegistryInit() is called from GetSessionDsmHandle()
>> which calls EnsureCurrentSession(), but
>> SharedRecordTypmodRegistryInit() does so again - sprinkling those
>> around liberally seems like it could hide bugs.
>
> Yeah. Will look into this.

One idea is to run InitializeSession() in InitPostgres() instead, so
that CurrentSession is initialized at startup, but initially empty.
See attached. (I realised that that terminology is a bit like a large
volume called FRENCH CUISINE which turns out to have just one recipe
for an omelette in it, but you have to start somewhere...) Better
ideas?

--
Thomas Munro
http://www.enterprisedb.com

Attachment Content-Type Size
shared-record-typmods-v9.patchset.tgz application/x-gzip 24.3 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Maksim Milyutin 2017-08-24 13:08:56 Re: auto_explain : log queries with wrong estimation
Previous Message Adrien Nayrat 2017-08-24 11:56:20 auto_explain : log queries with wrong estimation