PITR Redo Create Database fails - Mailing list pgsql-hackers

From Simon Riggs
Subject PITR Redo Create Database fails
Date
Msg-id 1089295080.17493.386.camel@stromboli
Whole thread Raw
Responses Re: PITR Redo Create Database fails
List 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





pgsql-hackers by date:

Previous
From: Andrew Piskorski
Date:
Subject: SAN, clustering, MPI, Backplane Re: Postgresql on SAN
Next
From: Alvaro Herrera
Date:
Subject: Re: PITR Redo Create Database fails