Re: PITR Redo Create Database fails - Mailing list pgsql-hackers

From Alvaro Herrera
Subject Re: PITR Redo Create Database fails
Date
Msg-id 20040708151933.GA8362@dcc.uchile.cl
Whole thread Raw
In response to PITR Redo Create Database fails  (Simon Riggs <simon@2ndquadrant.com>)
Responses Re: PITR Redo Create Database fails  (Simon Riggs <simon@2ndquadrant.com>)
List pgsql-hackers
On Thu, Jul 08, 2004 at 02:58:01PM +0100, Simon Riggs wrote:

> I've discovered that CREATE DATABASE doesn't redo correctly in an
> archive recovery test.
> 
> This isn't a bug --in the current code--, because when crash recovery
> occurs, the database directories are already there, so this only doesn't
> work when using the PITR patches. During archive recovery, nothing is
> there, so needs to be created.
> 
> It looks like CREATE DATABASE doesn't produce redo, nor is there a
> replay command created for it.

[...]

> The FileNameOpenFile fails when the first relation in the database is
> created. The code assumes that any failure of the FileNameOpenFile is
> because the file is already there, then tries to open it which also
> fails. The failure is caused by the fact that there is no directory (as
> well as no file), but that isn't tested for.

I don't think it's a good idea to just create a directory if it's not
already there.  It would mean creating a spurious directory with an
empty file if the data is corrupted and a wrong RelFileNode is in memory
for whatever reason.

The correct solution would be to emit a XLog record for CREATE
DATABASE ...

-- 
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"El destino baraja y nosotros jugamos" (A. Schopenhauer)


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: PITR Redo Create Database fails
Next
From: "Mark Wu"
Date:
Subject: working on support triggers on columns