Re: small parallel restore optimization
Andrew Dunstan <andrew@dunslane.net>
From: Andrew Dunstan <andrew@dunslane.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2009-03-09T00:45:43Z
Lists: pgsql-hackers
Tom Lane wrote: >> I've seen a recent error that suggests we are clobbering memory >> somewhere in the parallel code, as well as Olivier Prennant's reported >> error that suggests the same thing, although I'm blessed if I can see >> where it might be. Maybe some more eyeballs on the code would help. >> > > Can you put together even a weakly reproducible test case? Something > that only fails every tenth or hundredth time would still help. > > > 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. Has anyone got a better plan? cheers andrew