pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
PostgresNode::append_conf considered dangerous
2+ messages / 2 participants
[nested] [flat]

Commits from this thread:
  2017-04-22 8a19c1a373 551cc9af57  Make PostgresNode::append_conf append a newline automatically.
* PostgresNode::append_conf considered dangerous
@ 2017-04-22 20:19  Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Tom Lane @ 2017-04-22 20:19 UTC (permalink / raw)
  To: pgsql-hackers

Okay, so append_conf is perfectly straightforward about what it does:

	A newline is NOT automatically appended to the string.

However, I count at least eight places that are being lazy, like this:

  # Change a setting and restart
  $node->append_conf('postgresql.conf', 'hot_standby = on');
  $node->restart();

The worst part is that that works, as long as you don't do it more
than once in a script.  When you do it twice, though, you have a
syntactically invalid config file.  Thus for example this bit in
src/test/modules/commit_ts/t/003_standby_2.pl isn't doing anywhere
near what it thinks it's doing:

$master->append_conf('postgresql.conf', 'track_commit_timestamp = on');
$master->restart;
$master->append_conf('postgresql.conf', 'track_commit_timestamp = off');
$master->restart;

(I found that after deciding that PostgresNode::restart should complain
if pg_ctl failed.  The node is in fact not running after this, but the
existing test script fails to notice that.)

Now we could run around and make all these places do it the "right way",
like this other call:

$node_master->append_conf(
	'postgresql.conf', qq(
track_commit_timestamp = on
));

But (1) that's pretty darn ugly code, and (2) this fix does not prevent
future mistakes of the same ilk, which are obviously easy to make.

I think instead we should change append_conf to append a newline, and
simplify the callers that could thereby be simplified.  I don't see
any callers that would be broken by that; and we do not have any config
files in which extra blank lines are problematic.

			regards, tom lane


-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: PostgresNode::append_conf considered dangerous
@ 2017-04-23 00:56  Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Andrew Dunstan @ 2017-04-23 00:56 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-hackers



On 04/22/2017 04:19 PM, Tom Lane wrote:
>
> I think instead we should change append_conf to append a newline, and
> simplify the callers that could thereby be simplified.  I don't see
> any callers that would be broken by that; and we do not have any config
> files in which extra blank lines are problematic.
>
> 			


+1. Not sure how we survived so long with it the way it is.

cheers

andrew

-- 
Andrew Dunstan                https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services



-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2017-04-23 00:56 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-04-22 20:19 PostgresNode::append_conf considered dangerous Tom Lane <tgl@sss.pgh.pa.us>
2017-04-23 00:56 ` Andrew Dunstan <andrew.dunstan@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox