Re: END_OF_RECOVERY shutdowns and ResetUnloggedRelations()

From: Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: END_OF_RECOVERY shutdowns and ResetUnloggedRelations()
Date: 2014-09-24 11:36:05
Message-ID: 20140924113605.GA20227@toroid.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Andres, Robert.

I've attached four patches here.

1. Move the call to ResetUnloggedRelations(UNLOGGED_RELATION_INIT) to
earlier in StartupXLOG.

2. Inside that function, issue fsync()s for the main forks we create by
copying the _init fork.

3. A small fixup to add a const to "typedef char *FileName", because the
earlier patch gave me warnings about discarding const-ness. This is
consistent with many other functions in fd.c that take const char *.

4. Issue an fsync() on the data directory at startup if we need to
perform crash recovery.

I created some unlogged relations, performed an immediate shutdown, and
then straced postgres as it performed crash recovery. The changes in (2)
do indeed fsync the files we create by copying *_init, and don't fsync
anything else (at least not after I fixed a bug ;-).

I did not do anything about the END_OF_RECOVERY checkpoint setting the
ControlFile->state to DB_SHUTDOWNED, because it wasn't clear to me if
there was any agreement on what to do. I would be happy to submit a
followup patch if we reach some decision about it.

Is this what you had in mind?

-- Abhijit

Attachment Content-Type Size
0001-Call-ResetUnloggedRelations-UNLOGGED_RELATION_INIT-e.patch text/x-diff 1.9 KB
0002-Make-ResetUnloggedRelations-_INIT-fsync-newly-create.patch text/x-diff 2.1 KB
0003-Add-const-to-FileName-typedef-make-fsync_fname-use-i.patch text/x-diff 1.7 KB
0004-If-we-need-to-perform-crash-recovery-fsync-the-data-.patch text/x-diff 1.4 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2014-09-24 11:44:56 Re: make pg_controldata accept "-D dirname"
Previous Message Abhijit Menon-Sen 2014-09-24 11:21:03 Re: make pg_controldata accept "-D dirname"