Re: small parallel restore optimization

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: small parallel restore optimization
Date: 2009-03-09 01:19:20
Message-ID: 6902.1236561560@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> 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.

Ugh. But that doesn't explain the original trouble report on Unixware.

> 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.

I think we should try hard to keep this localized to fmtId(), rather
than changing the callers --- the latter would be a huge readability
hit. Is there a reasonable way to have fmtId use thread-local storage
for its PQExpBuffer pointer on Windows?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2009-03-09 01:25:53 Re: small parallel restore optimization
Previous Message Tom Lane 2009-03-09 01:14:26 Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail