Re: Proposal for Allow postgresql.conf values to be changed via SQL
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit kapila <amit.kapila@huawei.com>
Cc: Fujii Masao <masao.fujii@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>, Dimitri Fontaine <dimitri@2ndquadrant.fr>, "cedric@2ndquadrant.com" <cedric@2ndquadrant.com>, Robert Haas <robertmhaas@gmail.com>, Greg Smith <greg@2ndquadrant.com>, Josh Berkus <josh@agliodbs.com>, Magnus Hagander <magnus@hagander.net>, Christopher Browne <cbbrowne@gmail.com>, Alvaro Herrera <alvherre@2ndquadrant.com>
Date: 2012-11-24T17:26:02Z
Lists: pgsql-hackers
Amit kapila <amit.kapila@huawei.com> writes: > On Friday, November 23, 2012 10:10 PM Fujii Masao wrote: >> What happens if the server crashes while SET PERSISTENT is writing the >> setting to the file? A partial write occurs and restart of the server would fail >> because of corrupted postgresql.auto.conf? > This situation will not happen as SET PERSISTENT command will first write to ".lock" file and then at commit time, > rename it to ".auto.conf". Yes, the right way to write the config file is to write under a temporary name, fsync the file, and then use rename(2) to atomically move it into place. However, the above is contemplating some extra complexity that I think is useless and undesirable, namely postponing the rename until commit time. The point of the suggestion that SET PERSISTENT not be allowed inside a transaction block is so that you can write the file immediately rather than have to add commit-time mechanism to support the feature. Aside from being extra complexity, and some extra cycles added in *every single commit*, a post-commit write creates another way to have post-commit failures, which we cannot cope with in any sane way. regards, tom lane