Re: Use of 'cp -r' in CREATE DATABASE

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Use of 'cp -r' in CREATE DATABASE
Date: 2003-12-29 02:09:56
Message-ID: 3FEF8CF4.2030801@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:

>A final point is that implementing CREATE DATABASE via "cp -r" is and
>always has been fundamentally broken anyway, because of the lack of
>interlocking against other backends changing the source database.
>We have a very half-baked defense against that (erroring out if anyone
>else is connected to the source DB at the start of the copy) which
>I would dearly love to get rid of.
>

It struck me this morning that we could strengthen that defense
considerable with the addition of some checks after the copy on the
mtimes of the copied files. The additional code could be quite small and
fast.

Longer term, a robust mechanism for DB level locks would probably be
preferable, I guess, so I'm not sure if my idea is worth doing in the
mean time. Presumably it hasn't caused much of a problem up to now,
since most people are not likely to monkey with their template dbs at
the same time as trying to create dbs based on them.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Chris Travers 2003-12-29 02:13:20 Re: Variables in PostgreSQL? [was: Is my MySQL Gaining?]
Previous Message Chris Travers 2003-12-29 01:56:35 Re: Is my MySQL Gaining ?