Doug McNaught <doug@mcnaught.org> writes:
> AFAIK it's extremely bad practice in general to share a connection
> between two threads, unless you protect it with some kind of lock to
> avoid simultaneous use.
I suspect Doug's put his finger on the problem --- are you trying to
use the same PGconn object in both threads? Not a good idea at all.
libpq isn't thread-aware (mainly because of the portability problems
that would ensue), and it *will* break if you try to use the same
PGconn concurrently in two different threads.
regards, tom lane