Skip site navigation (1) Skip section navigation (2)

Re: initdb -S and tablespaces

From: Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: initdb -S and tablespaces
Date: 2014-10-30 09:00:28
Message-ID: 20141030090027.GA1214@toroid.org (view raw, whole thread or download thread mbox)
Thread:
Lists: pgsql-hackers
At 2014-09-29 11:54:10 +0200, andres(at)2ndquadrant(dot)com wrote:
>
> On 2014-09-29 14:09:01 +0530, Abhijit Menon-Sen wrote:
> > 
> > I just noticed that initdb -S ("Safely write all database files to disk
> > and exit") does (only) the following in perform_fsync:
> > 
> >     pre_sync_fname(pdir, true);
> >     walkdir(pg_data, pre_sync_fname);
> > 
> >     fsync_fname(pdir, true);
> >     walkdir(pg_data, fsync_fname);
> > 
> > walkdir() reads the directory and calls itself recursively for S_ISDIR
> > entries, or calls the function for S_ISREG entries… which means it
> > doesn't follow links.
> > 
> > Which means it doesn't fsync the contents of tablespaces.
> 
> Which means at least pg_upgrade is unsafe right
> now... c.f. 630cd14426dc1daf85163ad417f3a224eb4ac7b0.

Here's a proposed patch to initdb to make initdb -S fsync everything
under pg_tblspc. It introduces a new function that calls walkdir on
every entry under pg_tblspc. This is only one approach: I could have
also changed walkdir to follow links, but that would have required a
bunch of #ifdefs for Windows (because it doesn't have symlinks), and I
guessed a separate function with two calls might be easier to patch into
back branches. I've tested this patch under various conditions on Linux,
but it could use some testing on Windows.

-- Abhijit

Attachment: tblspclinks.diff
Description: text/x-diff (2.6 KB)

In response to

Responses

pgsql-hackers by date

Next:From: David RowleyDate: 2014-10-30 09:17:07
Subject: Re: WIP: multivariate statistics / proof of concept
Previous:From: Simon RiggsDate: 2014-10-30 08:58:05
Subject: Re: group locking: incomplete patch, just for discussion

Privacy Policy | About PostgreSQL
Copyright © 1996-2018 The PostgreSQL Global Development Group