agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
From: p.sun.fun@gmail.com
To: pgsql-sql@lists.postgresql.org
Subject: Re: libpq CREATE DATABASE operation from multiple treads
Date: Thu, 08 Oct 2020 15:04:24 -0500
Message-ID: <e532a64faac43651d4bec947409d42365607767f.camel@gmail.com> (raw)
In-Reply-To: <2623291.1602187023@sss.pgh.pa.us>
References: <390804abe88e4e9da9049f6e05c841783acaca47.camel@gmail.com>
	<2623291.1602187023@sss.pgh.pa.us>

Hi Tom.

Thanks for the quick response. In the function that I execute in each
thread, I create a new PGconn at the beginning. I expect that every
function caller (thread) should use a unique PGconn. I would not expect
that PGconn can be shared between threads. The documentation explicitly
says that.


On Thu, 2020-10-08 at 15:57 -0400, Tom Lane wrote:
> p.sun.fun@gmail.com writes:
> > I run this function using only one thread and everything works
> > great.
> > If I use two threads, the PQresultStatus(res) != PGRES_COMMAND_OK.
> 
> Are you trying to use the same PGconn from multiple threads?  That
> will not work --- at least not without interlocks that libpq on
> its own does not provide.
> 
> > Can the server handle CREATE DATABASE requests in parallel? 
> 
> Sure.  But they have to be issued over different connections.
> Any given connection can only do one thing at a time.
> 
> 			regards, tom lane






view thread (18+ messages)  latest in thread

Message-ID: <e532a64faac43651d4bec947409d42365607767f.camel@gmail.com>
Permalink:  ../e532a64faac43651d4bec947409d42365607767f.camel@gmail.com/
Also on:    postgresql.org/message-id/e532a64faac43651d4bec947409d42365607767f.camel@gmail.com

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: p.sun.fun@gmail.com, pgsql-sql@lists.postgresql.org
  Subject: Re: libpq CREATE DATABASE operation from multiple treads
  In-Reply-To: <e532a64faac43651d4bec947409d42365607767f.camel@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox