Hi Pieter, Thanks for the insight. On reflection, it is unreasonable of me to expect Postgres client to operate across multiple threads within one process. The failure mode supports that - as it was complaining that the database was already disconnected , when it tried to disconnect. Presumably using the same static data within the process.
I'll move to using different processes: just need to manage the connection pool as I want the number of processes to be configurable. Thanks, Alan -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Pieter Hintjens Sent: 31 January 2014 13:18 To: ZeroMQ development list Subject: Re: [zeromq-dev] Question about CZMQ threading and Postgres Hi Alan, zthread_fork and zthread_new will look the same to Postgres. The difference is for the CZMQ infrastructure; the first creates an "attached thread" (sharing the same context and with a pipe back to the parent), while the second creates a "detached thread" (shares nothing, so acts more like a separate process, and cannot talk over inproc to the parent). Could you post a *minimal* piece of code that provokes the error so we can look at it? Could be the Postgres client has static variables and simply can't be called from 2+ threads in the same process. In that case, it is trivial to solve. Create a single Postgres client thread (attached :-) and talk to it over inproc. -Pieter On Fri, Jan 31, 2014 at 12:47 PM, Alan Ward <[email protected]> wrote: > Hi, > I would like to find out if anyone has successfully run multiple > worker threads created by CZMQ zthread_fork, where each thread is the > same and running Postgres updates to the same database. > > My system works fine if I use one worker thread, but if I increase it > to > (say) 3, Postgres fails with (undocumented) YE000 errors. > > Searching the net finds some instances of this error being reported in > 2007 and it relates to problems with concurrent access from multiple threads. > > Should I be using zthread_new? > > Thanks, > Alan > > > _______________________________________________ > zeromq-dev mailing list > [email protected] > http://lists.zeromq.org/mailman/listinfo/zeromq-dev _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev ----- No virus found in this message. Checked by AVG - www.avg.com Version: 2014.0.4259 / Virus Database: 3684/7047 - Release Date: 01/30/14 _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
