Re: small parallel restore optimization

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: small parallel restore optimization
Date: 2009-03-09 01:25:53
Message-ID: 20090309012553.GO3821@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan wrote:

> I have found the source of the problem I saw. dumputils.c:fmtId() uses a
> static PQExpBuffer which it initialises the first time it's called. This
> gets clobbered by simultaneous calls by Windows threads.
>
> I could just make it auto and set it up on each call, but that could
> result in a non-trivial memory leak ... it's probably called a great
> many times. Or I could provide a parallel version where we pass in a
> PQExpBuffer that we create, one per thread, and is used by anything
> called by the parallel code. That seems like a bit of a potential
> footgun, though.

Could you use a different static PQExpBuffer on each thread?
pthread_getspecific sort of thing, only to be used on Windows.

BTW does fmtQualifiedId have the same problem?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2009-03-09 01:45:44 Re: small parallel restore optimization
Previous Message Tom Lane 2009-03-09 01:19:20 Re: small parallel restore optimization