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: 2015-03-10 07:49:48
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

At 2015-01-15 14:32:45 +0100, andres(at)2ndquadrant(dot)com wrote:
> What I am thinking of is that, currently, if you start the server for
> initial loading with fsync=off, and then restart it, you're open to
> data loss. So when the current config file setting is changed from off
> to on, we should fsync the data directory. Even if there was no crash
> restart.

Patch attached.


1. Renamed perform_fsync to fsync_recursively (otherwise it would read
2. Added ControlData->fsync_disabled to record whether fsync was ever
disabled while the server was running (tested in CreateCheckPoint)
3. Run fsync_recursively at startup only if fsync is enabled
4. Run it if we're doing crash recovery, or fsync was disabled
5. Use pg_flush_data in pre_sync_fname
6. Issue fsync on directories too
7. Tested that it works if pg_xlog is a symlink (no changes).

(In short, everything you mentioned in your earlier mail.)

Note that I set ControlData->fsync_disabled to false in BootstrapXLOG,
but it gets set to true during a later CreateCheckPoint(). This means
we run fsync again at startup after initdb. I'm not sure what to do
about that.

Is this about what you had in mind?

-- Abhijit

Attachment Content-Type Size
0001-Recursively-fsync-PGDATA-at-startup-if-needed.patch text/x-diff 8.2 KB

In response to


Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2015-03-10 08:05:20 Re: Proposal : REINDEX xxx VERBOSE
Previous Message Amit Kapila 2015-03-10 06:56:05 Re: Parallel Seq Scan