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:52:22 -0500
Message-ID: <cf26fe0aca8ce2769334ac4781a01eba89311b0e.camel@gmail.com> (raw)
In-Reply-To: <2624889.1602189369@sss.pgh.pa.us>
References: <390804abe88e4e9da9049f6e05c841783acaca47.camel@gmail.com>
	<CAAfz9KOVPRptcva6T97+VgLhYbqMJGC07yHVHMW3Ugxki6y6dA@mail.gmail.com>
	<124ce8dff8402159f20dec1bc1ac27e26ee39c23.camel@gmail.com>
	<2624889.1602189369@sss.pgh.pa.us>

On Thu, 2020-10-08 at 16:36 -0400, Tom Lane wrote:
> p.sun.fun@gmail.com writes:
> > Indeed, this is a FATAL_ERROR. From two threads I got:
> > // Thread #1
> > FATAL_ERROR: ERROR:  source database "template1" is being accessed
> > by
> > other users
> > DETAIL:  There is 1 other session using the database.
> 
> You'd be better off to connect to some other database than template1;

What would be the best strategy to create a database from user
standpoint of view? If we have an API to create a database on a server.
The user doesn't know about database(s) yet. The possible option would
be: to check the result status and if is not COMMAND_OK, probably
connection should be dropped and established again.  

May be not so elegant but at least safe and stable. 

> not only just for this purpose, but in general.  If you are issuing
> random commands in template1, there's a risk of modifying that
> database
> unexpectedly and thereby changing the contents of databases created
> in future.
> 
> 			regards, tom lane






view thread (18+ messages)  latest in thread

Message-ID: <cf26fe0aca8ce2769334ac4781a01eba89311b0e.camel@gmail.com>
Permalink:  ../cf26fe0aca8ce2769334ac4781a01eba89311b0e.camel@gmail.com/
Also on:    postgresql.org/message-id/cf26fe0aca8ce2769334ac4781a01eba89311b0e.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: <cf26fe0aca8ce2769334ac4781a01eba89311b0e.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