PITR Redo Create Database fails

From: Simon Riggs <simon(at)2ndquadrant(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: PITR Redo Create Database fails
Date: 2004-07-08 13:58:01
Message-ID: 1089295080.17493.386.camel@stromboli
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


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.

That's not a big deal - maybe - because creating a directory for that
database fixes it, with no further problems.

Could somebody that knows about tablespaces etc, look into this and
suggest a solution/patch? I need time to complete the PITR features...

The failing code is copied below, from src/backend/storagesmgr/md.c
----------------------------------------------
static MdfdVec *
mdopen(SMgrRelation reln, bool allowNotFound)
{
MdfdVec *mdfd;
char *path;
File fd;

/* No work if already open */
if (reln->md_fd)
return reln->md_fd;

path = relpath(reln->smgr_rnode);

fd = FileNameOpenFile(path, O_RDWR | PG_BINARY, 0600);

if (fd < 0)
{
/*
-----------------------------------------------

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.

It would be easy to create the directory at this point IF that didn't
conflict with tablespaces etc..

Please look into this if possible,

Thanks,

Best Regards, Simon Riggs

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-07-08 15:19:33 Re: PITR Redo Create Database fails
Previous Message Andrew Piskorski 2004-07-08 12:22:21 SAN, clustering, MPI, Backplane Re: Postgresql on SAN