CREATE DATABASE fails when template1 being accessed ...

Lists: pgsql-hackers
From: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: CREATE DATABASE fails when template1 being accessed ...
Date: 2005-05-31 17:53:41
Message-ID: 20050531145233.D933@ganymede.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

ERROR: source database "template1" is being accessed by other users

Why is this not allowed? Not that there is generally a reason to be in
template1, but am curious as to why it prevents a new DB from being
created if someone is connected to it ...

----
Marc G. Fournier Hub.Org Networking Services (http://www.hub.org)
Email: scrappy(at)hub(dot)org Yahoo!: yscrappy ICQ: 7615664


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE DATABASE fails when template1 being accessed ...
Date: 2005-05-31 18:49:09
Message-ID: 17108.1117565349@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> ERROR: source database "template1" is being accessed by other users

> Why is this not allowed?

It's a rather lame attempt to ensure that you don't get a corrupt copy
due to the database changing while you copy it ... I'd like to find
a better way to do it ...

regards, tom lane


From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE DATABASE fails when template1 being accessed ...
Date: 2005-05-31 18:54:26
Message-ID: 20050531185426.GA13127@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, May 31, 2005 at 14:53:41 -0300,
"Marc G. Fournier" <scrappy(at)postgresql(dot)org> wrote:
>
>
> ERROR: source database "template1" is being accessed by other users
>
> Why is this not allowed? Not that there is generally a reason to be in
> template1, but am curious as to why it prevents a new DB from being
> created if someone is connected to it ...

Because if someone changes something in the database while it is being
copied, the newly created database will probably be messed up.


From: Alvaro Herrera <alvherre(at)surnet(dot)cl>
To: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE DATABASE fails when template1 being accessed ...
Date: 2005-05-31 19:08:34
Message-ID: 20050531190834.GB9073@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, May 31, 2005 at 02:53:41PM -0300, Marc G. Fournier wrote:

> ERROR: source database "template1" is being accessed by other users
>
> Why is this not allowed? Not that there is generally a reason to be in
> template1, but am curious as to why it prevents a new DB from being
> created if someone is connected to it ...

Because we copy the files directly. So if someone modifies one file in
the middle of the copy, or, say, we copy one index and later the table
and someone inserts into a table in the middle, then the new database is
in an inconsistent state.

There has been talk about fixing this in the past, but conclusion seems
to be "too hard to fix for too little benefit."

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"No hay hombre que no aspire a la plenitud, es decir,
la suma de experiencias de que un hombre es capaz"


From: Alvaro Herrera <alvherre(at)surnet(dot)cl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE DATABASE fails when template1 being accessed ...
Date: 2005-05-31 20:01:00
Message-ID: 20050531200059.GD9257@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, May 31, 2005 at 02:49:09PM -0400, Tom Lane wrote:
> "Marc G. Fournier" <scrappy(at)postgresql(dot)org> writes:
> > ERROR: source database "template1" is being accessed by other users
>
> > Why is this not allowed?
>
> It's a rather lame attempt to ensure that you don't get a corrupt copy
> due to the database changing while you copy it ... I'd like to find
> a better way to do it ...

You sounded less enthusiastic about it on january:

http://archives.postgresql.org/pgsql-bugs/2005-01/msg00395.php

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"Investigación es lo que hago cuando no sé lo que estoy haciendo"
(Wernher von Braun)


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)surnet(dot)cl>
Cc: "Marc G(dot) Fournier" <scrappy(at)postgresql(dot)org>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: CREATE DATABASE fails when template1 being accessed ...
Date: 2005-05-31 20:28:56
Message-ID: 23254.1117571336@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)surnet(dot)cl> writes:
> On Tue, May 31, 2005 at 02:49:09PM -0400, Tom Lane wrote:
>> It's a rather lame attempt to ensure that you don't get a corrupt copy
>> due to the database changing while you copy it ... I'd like to find
>> a better way to do it ...

> You sounded less enthusiastic about it on january:
> http://archives.postgresql.org/pgsql-bugs/2005-01/msg00395.php

Well, I was expressing dissatisfaction with the obvious way of fixing
it. If we knew a low-overhead way to fix it I'd be much more
enthusiastic ...

regards, tom lane


From: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Tablespace-level Block Size Definitions
Date: 2005-05-31 20:55:29
Message-ID: 429CCF41.9080806@tvi.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hey everyone,

I'm sure this has been thought of but was wondering whether anyone had
discussed the allowance of run-time block size specifications at the
tablespace level? I know that a change such as this would substantially
impact buffer operations, transactions, access methods, the storage
manager, and a lot of other stuff, however it would give an
administrator the ability to inhance performance for specific applications.

Arguably, one can set the block size at compile-time, but for a system
running multiple databases it *may* be a nice feature. Would it be used
a lot? Probably not. Would I use it? Certainly! Would some of my
clients use it? Yes.

Perhaps a TODO item for some advantageous company to fund?

-Jonah


From: Bricklen Anderson <BAnderson(at)PresiNET(dot)com>
To: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Tablespace-level Block Size Definitions
Date: 2005-05-31 21:01:13
Message-ID: 429CD099.5020804@PresiNET.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jonah H. Harris wrote:
> Hey everyone,
>
> I'm sure this has been thought of but was wondering whether anyone had
> discussed the allowance of run-time block size specifications at the
> tablespace level? I know that a change such as this would substantially
> impact buffer operations, transactions, access methods, the storage
> manager, and a lot of other stuff, however it would give an
> administrator the ability to inhance performance for specific applications.
>
> Arguably, one can set the block size at compile-time, but for a system
> running multiple databases it *may* be a nice feature. Would it be used
> a lot? Probably not. Would I use it? Certainly! Would some of my
> clients use it? Yes.
>
> Perhaps a TODO item for some advantageous company to fund?
>
> -Jonah

Have you used Oracle's version as well?

--
_______________________________

This e-mail may be privileged and/or confidential, and the sender does
not waive any related rights and obligations. Any distribution, use or
copying of this e-mail or the information it contains by other than an
intended recipient is unauthorized. If you received this e-mail in
error, please advise me (by return e-mail or otherwise) immediately.
_______________________________


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Tablespace-level Block Size Definitions
Date: 2005-05-31 21:05:02
Message-ID: 2060.1117573502@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Jonah H. Harris" <jharris(at)tvi(dot)edu> writes:
> I'm sure this has been thought of but was wondering whether anyone had
> discussed the allowance of run-time block size specifications at the
> tablespace level?

Can you produce any evidence whatsoever that this could be worth the cost?
Aside from the nontrivial development effort needed, there would be
runtime inefficiencies created --- for instance, inefficient use of
buffer pool storage because it'd no longer be true that any buffer could
hold any block. Without some pretty compelling evidence, I wouldn't
even waste any time thinking about it ...

regards, tom lane


From: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
To: Bricklen Anderson <BAnderson(at)PresiNET(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Tablespace-level Block Size Definitions
Date: 2005-05-31 21:05:34
Message-ID: 429CD19E.6000407@tvi.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Yes,

That is what I/my clients have been discussing. It is a nifty
performance feature.

Bricklen Anderson wrote:

> Jonah H. Harris wrote:
>
>> Hey everyone,
>>
>> I'm sure this has been thought of but was wondering whether anyone
>> had discussed the allowance of run-time block size specifications at
>> the tablespace level? I know that a change such as this would
>> substantially impact buffer operations, transactions, access methods,
>> the storage manager, and a lot of other stuff, however it would give
>> an administrator the ability to inhance performance for specific
>> applications.
>>
>> Arguably, one can set the block size at compile-time, but for a
>> system running multiple databases it *may* be a nice feature. Would
>> it be used a lot? Probably not. Would I use it? Certainly! Would
>> some of my clients use it? Yes.
>>
>> Perhaps a TODO item for some advantageous company to fund?
>>
>> -Jonah
>
>
> Have you used Oracle's version as well?
>


From: Alvaro Herrera <alvherre(at)surnet(dot)cl>
To: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Tablespace-level Block Size Definitions
Date: 2005-05-31 21:10:34
Message-ID: 20050531211033.GA10621@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, May 31, 2005 at 02:55:29PM -0600, Jonah H. Harris wrote:
> Hey everyone,
>
> I'm sure this has been thought of but was wondering whether anyone had
> discussed the allowance of run-time block size specifications at the
> tablespace level? I know that a change such as this would substantially
> impact buffer operations, transactions, access methods, the storage
> manager, and a lot of other stuff, however it would give an
> administrator the ability to inhance performance for specific applications.

The problem I see with this proposal is that the buffer manager knows
how to handle only a equally-sized pages. And the shared memory stuff
gets sized according to size * num_pages. So what happens if a certain
tablespace A with pagesize=X gets to have a lot of its pages cached,
evicting pages from tablespace B with pagesize=Y, where Y < X?

While I think it could be workable to make the buffer manager handle
variable-sized pages, it could prove difficult to handle the shared
memory. (We can't resize it while the server is running.)

--
Alvaro Herrera (<alvherre[a]surnet.cl>)
"La principal característica humana es la tontería"
(Augusto Monterroso)


From: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Tablespace-level Block Size Definitions
Date: 2005-05-31 23:06:40
Message-ID: 429CEE00.5030009@tvi.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom,

You and I both know that depending on the application and data,
different block sizes are beneficial. As for actual statistics due to
overhead, I don't know what I can give you.

I can provide stats from an application which fits the case for multiple
block sizes on Oracle, but Oracle accounts for this overhead anyway. I
can give you academic research studies, which may be fairly unreliable
in a real-world setting.

I don't disagree at all that supporting multiple block sizes would be
one big PITA to implement and that it would add overhead. I am just
saying that it would be a useful feature for *some* people. Granted,
this isn't a large population (at this point in time), but applications
have been written and optimized using these features.

You are all really smart and I'm just putting this suggestion out there
to stew on. I don't want you guys to think that I'm just throwing out
every Oracle feature I can find, just that when I'm working on an
application which benefits from a feature which would similarly be
useful in PostgreSQL, I suggest it. You guys have been working on pgsql
far longer than I, so for my ideas, chew 'em up and spit 'em out, I
don't take offense. As I stated initially, this wouldn't even be a
low-priority thing, just a nicety that IMHO would be well-placed in a
TODO (possibly as "investigate usability and feasability of block sizes
by tablespace").

Tom, I respect your insight and would be more than happy to get you any
information you'd like concerning this subject or any other I may
suggest. I don't want to waste your time, so if there is anything in
particular you want to see, just let me know. Thanks.

-Jonah

Tom Lane wrote:

>"Jonah H. Harris" <jharris(at)tvi(dot)edu> writes:
>
>
>>I'm sure this has been thought of but was wondering whether anyone had
>>discussed the allowance of run-time block size specifications at the
>>tablespace level?
>>
>>
>
>Can you produce any evidence whatsoever that this could be worth the cost?
>Aside from the nontrivial development effort needed, there would be
>runtime inefficiencies created --- for instance, inefficient use of
>buffer pool storage because it'd no longer be true that any buffer could
>hold any block. Without some pretty compelling evidence, I wouldn't
>even waste any time thinking about it ...
>
> regards, tom lane
>
>---------------------------(end of broadcast)---------------------------
>TIP 7: don't forget to increase your free space map settings
>
>


From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jonah H(dot) Harris" <jharris(at)tvi(dot)edu>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Tablespace-level Block Size Definitions
Date: 2005-05-31 23:57:19
Message-ID: 1117583839.3844.828.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2005-05-31 at 17:05 -0400, Tom Lane wrote:
> "Jonah H. Harris" <jharris(at)tvi(dot)edu> writes:
> > I'm sure this has been thought of but was wondering whether anyone had
> > discussed the allowance of run-time block size specifications at the
> > tablespace level?
>
> Can you produce any evidence whatsoever that this could be worth the cost?
> Aside from the nontrivial development effort needed, there would be
> runtime inefficiencies created --- for instance, inefficient use of
> buffer pool storage because it'd no longer be true that any buffer could
> hold any block. Without some pretty compelling evidence, I wouldn't
> even waste any time thinking about it ...

DB2 has had multiple page size support for some time, though the default
was always 4KB. They have just reintroduced the option to have a single
page size > 4KB across the database. They would not do this if there was
not clear evidence that multiple block sizes were inefficient in some
reasonably common cases.

I must admit when I cam here, I thought the same as Jonah. But the I
haven't seen any recent evidence for any benefit. Its a real pain trying
to test this and very difficult to change once its been setup. There's a
great deal more benefit to be had from many other areas, IMHO.

Best Regards, Simon Riggs