Re: [9.4] Make full_page_writes only settable on server start?

Lists: pgsql-hackers
From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 02:10:57
Message-ID: 1378174257.19551.8.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

There is a significant amount of code supporting the changing of
full_page_writes while the server is running, including an
XLOG_FPW_CHANGE wal record. But I don't see the use-case; surely almost
nobody changes this on a running server, because either your filesystem
guarantees atomic page writes for you or not.

I'd like to submit a patch to just make it into a PGC_POSTMASTER and
remove the code to support changing it.

Then, I intend to write another patch to make the full-page writes for
checksums honor the full_page_writes setting. That will be easier to
write once it's a PGC_POSTMASTER.

Any reason to keep the setting as a PGC_SIGHUP?

Regards,
Jeff Davis


From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 03:00:11
Message-ID: CAM3SWZTUrRYdFk=Z=a7NYdRQSS497qh=0pW37hH2Rt45Bs+z0A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 2, 2013 at 7:10 PM, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> I'd like to submit a patch to just make it into a PGC_POSTMASTER and
> remove the code to support changing it.

Makes sense to me.

I wonder, is anyone really running in production with full_page_writes
off? I talked to someone a while ago who used Postgres on ZFS with
data journaling, and was perfectly well aware of the fact that
theoretically he could safely turn the setting off, and yet chose not
to. Now, I know that Greg Smith's book describes the conditions in
which it's acceptable and the precautions that should be taken and so
on, but in my (admittedly relatively limited) experience, no one
actually does it in production. My sample size for people who at least
considered doing it (that both believed that Postgres could write
pages atomically on their hardware/FS, and also knew that
full_page_writes exists and what it means) is only 1.

At least in people's minds, it might be that the knowledge that no one
runs with full_page_writes off is enough to put them off. It's like
building Postgres with a non-standard BLCKSZ -- even if you had solid
evidence that it would help performance in your case, would you really
want to do it?

--
Peter Geoghegan


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 12:19:35
Message-ID: 20130903121935.GB5783@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2013-09-02 19:10:57 -0700, Jeff Davis wrote:
> There is a significant amount of code supporting the changing of
> full_page_writes while the server is running, including an
> XLOG_FPW_CHANGE wal record. But I don't see the use-case; surely almost
> nobody changes this on a running server, because either your filesystem
> guarantees atomic page writes for you or not.
>
> I'd like to submit a patch to just make it into a PGC_POSTMASTER and
> remove the code to support changing it.

I've wondered about that before. But always decided that we wouldn't
gain all that much by making it PGC_POSTMASTER since the effective value
of full_page_writes still needs to be changeable at runtime since we
need to force-enable full page writes during a pg_start/stop_backup().

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Stephen Frost <sfrost(at)snowman(dot)net>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 14:43:06
Message-ID: 20130903144306.GW2706@tamriel.snowman.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

* Peter Geoghegan (pg(at)heroku(dot)com) wrote:
> I wonder, is anyone really running in production with full_page_writes
> off?

The simple answer to this is "yes, definitely."

I don't know if they change it on-the-fly, but I doubt it.

Thanks,

Stephen


From: Josh Berkus <josh(at)agliodbs(dot)com>
To: Peter Geoghegan <pg(at)heroku(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 16:23:15
Message-ID: 52260CF3.1010600@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter,

> I wonder, is anyone really running in production with full_page_writes
> off?

We're doing so with clients on Joyent (ZFS). And also for "ephemeral"
postgres instances -- ones where we've also turned off fsync.

It's also quite reasonable to assume that future filesystems will also
be able to make better torn page guarantees.

So it should remain a setting. I see no reason why it should be a
SIGHUP setting, though, if there's any code maintenance required to
support it -- frankly, I only change this setting at first system
deployment.

--
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com


From: Peter Geoghegan <pg(at)heroku(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 17:42:17
Message-ID: CAM3SWZRi1_gXa5WgMHRr+52Ekhd3wq=ZJH6ihSZ0ASatPq0ftw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Sep 3, 2013 at 9:23 AM, Josh Berkus <josh(at)agliodbs(dot)com> wrote:
> So it should remain a setting.

Sure. I wasn't suggesting deprecating it or anything.

--
Peter Geoghegan


From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Peter Geoghegan <pg(at)heroku(dot)com>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 17:47:22
Message-ID: CABUevExaZfDo5sCNNNuCpwk5aXFd4uQ+7xQL0FsOzfJXdm_jAg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sep 3, 2013 6:23 PM, "Josh Berkus" <josh(at)agliodbs(dot)com> wrote:
>
> Peter,
>
>
> > I wonder, is anyone really running in production with full_page_writes
> > off?
>
> We're doing so with clients on Joyent (ZFS). And also for "ephemeral"
> postgres instances -- ones where we've also turned off fsync.
>
> It's also quite reasonable to assume that future filesystems will also
> be able to make better torn page guarantees.
>
> So it should remain a setting. I see no reason why it should be a
> SIGHUP setting, though, if there's any code maintenance required to
> support it -- frankly, I only change this setting at first system
> deployment.
>

This matches my experience as well - people certainly use it, but don't
change it during runtime.

Not having looked at the code, but doesn't pg_start_backup use at least
parts of the same code path? That one will definitely still be able to
modify it at runtime....

/Magnus


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 19:42:37
Message-ID: CA+TgmoaKrg94gz0s+goi4k+sFmEsp3eH7UCBReJRH7s5F_nEbg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Sep 2, 2013 at 10:10 PM, Jeff Davis <pgsql(at)j-davis(dot)com> wrote:
> There is a significant amount of code supporting the changing of
> full_page_writes while the server is running, including an
> XLOG_FPW_CHANGE wal record. But I don't see the use-case; surely almost
> nobody changes this on a running server, because either your filesystem
> guarantees atomic page writes for you or not.

Although this is true, the administrator's estimate of whether that
guarantee is or is not provided might not be as consistent as the
hardware behavior itself. I am generally of the feeling that having
to restart the server to change setting sucks, and while it surely
sucks less for this setting than some, mostly because few people
change this setting in the first place, I'm still not convinced that
this is moving in the right direction.

> I'd like to submit a patch to just make it into a PGC_POSTMASTER and
> remove the code to support changing it.
>
> Then, I intend to write another patch to make the full-page writes for
> checksums honor the full_page_writes setting. That will be easier to
> write once it's a PGC_POSTMASTER.

I don't think I know exactly what this means.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Peter Geoghegan <pg(at)heroku(dot)com>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-03 19:44:01
Message-ID: 20130903194401.GI21874@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, Sep 3, 2013 at 07:47:22PM +0200, Magnus Hagander wrote:
>
> On Sep 3, 2013 6:23 PM, "Josh Berkus" <josh(at)agliodbs(dot)com> wrote:
> >
> > Peter,
> >
> >
> > > I wonder, is anyone really running in production with full_page_writes
> > > off?
> >
> > We're doing so with clients on Joyent (ZFS). And also for "ephemeral"
> > postgres instances -- ones where we've also turned off fsync.
> >
> > It's also quite reasonable to assume that future filesystems will also
> > be able to make better torn page guarantees.
> >
> > So it should remain a setting. I see no reason why it should be a
> > SIGHUP setting, though, if there's any code maintenance required to
> > support it -- frankly, I only change this setting at first system
> > deployment.
> >
>
> This matches my experience as well - people certainly use it, but don't change
> it during runtime.
>
> Not having looked at the code, but doesn't pg_start_backup use at least parts
> of the same code path? That one will definitely still be able to modify it at
> runtime....

Yes, this was already mentioned in the thread, but didn't get noticed by
a few folks. In summary, no changes needed here.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +


From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-04 14:57:15
Message-ID: 1378306635.23979.15.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2013-09-03 at 15:42 -0400, Robert Haas wrote:
> Although this is true, the administrator's estimate of whether that
> guarantee is or is not provided might not be as consistent as the
> hardware behavior itself. I am generally of the feeling that having
> to restart the server to change setting sucks, and while it surely
> sucks less for this setting than some, mostly because few people
> change this setting in the first place, I'm still not convinced that
> this is moving in the right direction.

I think code complexity matters quite a lot. If we can eliminate some
complex code in a complex area, and all we give up is a feature with
essentially no use case, that sounds like we're moving in the right
direction to me.

I suppose some might be using it as a hack when they really just want to
temporarily disable WAL during a load or something. Seems like a blunt
tool though, and I haven't heard of anyone doing that or suggesting it.
And it doesn't store the page hole anyway, so the FPI during a load is
ordinarily quite small.

> > Then, I intend to write another patch to make the full-page writes for
> > checksums honor the full_page_writes setting. That will be easier to
> > write once it's a PGC_POSTMASTER.
>
> I don't think I know exactly what this means.

XLogSaveBufferForHint() calls XLogCheckBuffer() but doesn't also look at
the full page writes setting (like in XLogInsert()). That means, if
checksums are enabled and full_page_writes is off, we'll still write
some full page images for checksums. I'd like to remedy that.

Regards,
Jeff Davis


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-04 15:00:55
Message-ID: 20130904150055.GC11189@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2013-09-04 07:57:15 -0700, Jeff Davis wrote:
> XLogSaveBufferForHint() calls XLogCheckBuffer() but doesn't also look at
> the full page writes setting (like in XLogInsert()). That means, if
> checksums are enabled and full_page_writes is off, we'll still write
> some full page images for checksums. I'd like to remedy that.

I don't think that's really as easy as it sounds without removing the
ability to do base backups with full_page_writes = off. The interlocking
that would require makes things complex...
Personally I'd rather forbid enabling checkpoints in the combination
with full_page_writes = off. That doesn't seem like a good idea to me
and I am far from convinced it's actually going to work in all corner cases.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-04 15:32:46
Message-ID: 3011.1378308766@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> On Tue, 2013-09-03 at 15:42 -0400, Robert Haas wrote:
>> Although this is true, the administrator's estimate of whether that
>> guarantee is or is not provided might not be as consistent as the
>> hardware behavior itself. I am generally of the feeling that having
>> to restart the server to change setting sucks, and while it surely
>> sucks less for this setting than some, mostly because few people
>> change this setting in the first place, I'm still not convinced that
>> this is moving in the right direction.

> I think code complexity matters quite a lot. If we can eliminate some
> complex code in a complex area, and all we give up is a feature with
> essentially no use case, that sounds like we're moving in the right
> direction to me.

Isn't this whole discussion academic in view of Andres' point?
http://www.postgresql.org/message-id/20130903121935.GB5783@awork2.anarazel.de

regards, tom lane


From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-04 15:49:37
Message-ID: 1378309777.23979.39.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 2013-09-04 at 17:00 +0200, Andres Freund wrote:
> On 2013-09-04 07:57:15 -0700, Jeff Davis wrote:
> > XLogSaveBufferForHint() calls XLogCheckBuffer() but doesn't also look at
> > the full page writes setting (like in XLogInsert()). That means, if
> > checksums are enabled and full_page_writes is off, we'll still write
> > some full page images for checksums. I'd like to remedy that.
>
> I don't think that's really as easy as it sounds without removing the
> ability to do base backups with full_page_writes = off. The interlocking
> that would require makes things complex...

I didn't dig into that part yet. I was mostly distracted by the code to
support changing full_page_writes with SIGHUP.

One option would be to have XLogInsert return early if full_page_writes
is off, it's an XLOG_FPI record, and forcePageWrites is off.

> Personally I'd rather forbid enabling checkpoints in the combination
> with full_page_writes = off. That doesn't seem like a good idea to me
> and I am far from convinced it's actually going to work in all corner cases.

Hmm. It's good to be cautious when deploying on a less-common
configuration. However, I don't think it's a good idea to reject
seemingly valid combinations that are supposed to work due to a lack of
confidence in the review/testing process.

Might be an area warranting some further review and testing; I'll take a
look, but feel free to tell me if you can think of specific problem
areas.

Regards,
Jeff Davis


From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)2ndquadrant(dot)com>, Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-04 16:23:20
Message-ID: 1378311800.23979.63.camel@jdavis
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, 2013-09-04 at 11:32 -0400, Tom Lane wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> > I think code complexity matters quite a lot. If we can eliminate some
> > complex code in a complex area, and all we give up is a feature with
> > essentially no use case, that sounds like we're moving in the right
> > direction to me.
>
> Isn't this whole discussion academic in view of Andres' point?

Maybe "complex code" was an overstatement. We'd be able to eliminate the
XLOG_FPW_CHANGE, UpdateFullPageWrites(), and one of the members of
XLogCtlInsert; and make xlog.c slightly shorter in the process.

The first time I looked at doing the patch to honor full_page_writes=off
when checksums are on, the fact that fullPageWrites was changeable was a
distraction. Since I saw little or no value in what the code offered, my
instinct was to see if we could get rid of it.

It looks like Simon went to significant effort to maintain the
full_page_writes as a PGC_SUGHUP:

http://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=8366c780

Maybe he has the best perspective on the value versus complexity?

Regards,
Jeff Davis


From: Andres Freund <andres(at)2ndquadrant(dot)com>
To: Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Simon Riggs <simon(at)2ndQuadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-04 16:55:46
Message-ID: 20130904165546.GE32316@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 2013-09-04 09:23:20 -0700, Jeff Davis wrote:
> On Wed, 2013-09-04 at 11:32 -0400, Tom Lane wrote:
> > Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> > > I think code complexity matters quite a lot. If we can eliminate some
> > > complex code in a complex area, and all we give up is a feature with
> > > essentially no use case, that sounds like we're moving in the right
> > > direction to me.
> >
> > Isn't this whole discussion academic in view of Andres' point?
>
> Maybe "complex code" was an overstatement. We'd be able to eliminate the
> XLOG_FPW_CHANGE, UpdateFullPageWrites(), and one of the members of
> XLogCtlInsert; and make xlog.c slightly shorter in the process.

That path is also executed during a normal restart and during
promotion. Check the invocation of UpdateFullPageWrites() in
StartupXLOG(). Note that a standby needs to be able to follow a
primaries full_page_writes setting during a promotion.

Greetings,

Andres Freund

--
Andres Freund http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services


From: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Jeff Davis <pgsql(at)j-davis(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [9.4] Make full_page_writes only settable on server start?
Date: 2013-09-05 04:23:19
Message-ID: CAHGQGwGYtiskKskWNQpB4rCgywq64vFtr_pSaRSy+zYVtfWXZQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Sep 5, 2013 at 1:55 AM, Andres Freund <andres(at)2ndquadrant(dot)com> wrote:
> On 2013-09-04 09:23:20 -0700, Jeff Davis wrote:
>> On Wed, 2013-09-04 at 11:32 -0400, Tom Lane wrote:
>> > Jeff Davis <pgsql(at)j-davis(dot)com> writes:
>> > > I think code complexity matters quite a lot. If we can eliminate some
>> > > complex code in a complex area, and all we give up is a feature with
>> > > essentially no use case, that sounds like we're moving in the right
>> > > direction to me.
>> >
>> > Isn't this whole discussion academic in view of Andres' point?
>>
>> Maybe "complex code" was an overstatement. We'd be able to eliminate the
>> XLOG_FPW_CHANGE, UpdateFullPageWrites(), and one of the members of
>> XLogCtlInsert; and make xlog.c slightly shorter in the process.
>
> That path is also executed during a normal restart and during
> promotion. Check the invocation of UpdateFullPageWrites() in
> StartupXLOG(). Note that a standby needs to be able to follow a
> primaries full_page_writes setting during a promotion.

Yes, this is required for the backup from the standby.

If we make the GUC contect to PGC_POSTMASTER, I think that
we can remove XLOG_FPW_CHANGE and treat full_page_writes
the same way as wal_level, max_connections, i.e., the parameter
which CheckRequiredParameterValues() handles.

Regards,

--
Fujii Masao