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,


Best Regards, Simon Riggs

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 5 | next ›
Discussion Overview
grouppgsql-hackers @
postedJul 8, '04 at 1:58p
activeJul 9, '04 at 6:56p

2 users in discussion

Simon Riggs: 3 posts Alvaro Herrera: 2 posts



site design / logo © 2021 Grokbase