Re: initdb -S and tablespaces - Mailing list pgsql-hackers

From Abhijit Menon-Sen
Subject Re: initdb -S and tablespaces
Date
Msg-id 20150115053243.GA29279@toroid.org
Whole thread Raw
In response to Re: initdb -S and tablespaces  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: initdb -S and tablespaces
List pgsql-hackers
At 2015-01-14 11:59:08 +0100, andres@2ndquadrant.com wrote:
>
> > +    if (ControlFile->state != DB_SHUTDOWNED &&
> > +        ControlFile->state != DB_SHUTDOWNED_IN_RECOVERY)
> > +        perform_fsync(data_directory);
> > +
> 
> a) Please think of a slightly more descriptive name than perform_fsync

OK. (I just copied the name initdb uses, because at the time I was still
thinking in terms of a later patch moving this to src/common.) What do
you think of fsync_recursively? fsync_pgdata?

I think fsync_recursively(data_directory) reads well.

> b) I think we should check here whether fsync is enabled.

OK, will do.

> c) I'm wondering if we should add fsync to the control file and also
>    perform an fsync if the last shutdown was clear, but fsync was
>    disabled.

Explain? "Add fsync to the control file" means store the value of the
fsync GUC setting in the control file? And would the fsync you mention
be dependent on the setting, or unconditional?

> > +static void
> > +pre_sync_fname(char *fname, bool isdir)
> > +{
> 
> this essentially already exists in the backend inparts. C.f.
> pg_flush_data.

OK, I missed that. I'll rework the patch to use it.

> Theoretically you should also invoke fsync on directories.

OK.

> > +     * We need to name the parent of PGDATA.  get_parent_directory() isn't
> > +     * enough here, because it can result in an empty string.
> > +     */
> > +    snprintf(pdir, MAXPGPATH, "%s/..", pg_data);
> > +    canonicalize_path(pdir);
> 
> Hm. Why is this neded? Just syncing . should work?

Not sure, will investigate.

Thanks.

-- Abhijit



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: pg_rewind in contrib
Next
From: Craig Ringer
Date:
Subject: Define and document a guaranteed ordering for RETURNING?