[zeromq-dev] Question about CZMQ threading and Postgres

Pieter Hintjens ph at imatix.com
Fri Jan 31 14:17:57 CET 2014


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 <alan.ward at btinternet.com> 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
> zeromq-dev at lists.zeromq.org
> http://lists.zeromq.org/mailman/listinfo/zeromq-dev



More information about the zeromq-dev mailing list