Re: small parallel restore optimization - Mailing list pgsql-hackers

From Tom Lane
Subject Re: small parallel restore optimization
Date
Msg-id 6902.1236561560@sss.pgh.pa.us
Whole thread Raw
In response to Re: small parallel restore optimization  (Andrew Dunstan <andrew@dunslane.net>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.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


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Next
From: Alvaro Herrera
Date:
Subject: Re: small parallel restore optimization