postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail

Lists: pgsql-hackers
From: Selena Deckelmann <selena(at)endpoint(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Date: 2009-03-08 23:27:28
Message-ID: 49B45460.6040108@endpoint.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

ParseConfigFile currently exits on the first parsing error. Changed
guc_file.l to report all parsing errors before exiting:
* Moved parse_error: block inside while() loop
* Removed cleanup_exit: and associated 'goto'
* Added ereport if ParseConfigFile() returns false
* changed OK to ok ;)
* Added comment - TODO: Report bogus variables in addition to parsing
errors before bailing out

-selena

--
Selena Deckelmann
End Point Corporation
selena(at)endpoint(dot)com
503-282-2512

Attachment Content-Type Size
postgresql.conf_report_all_parser_errors_v1.patch text/plain 3.3 KB

From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: Selena Deckelmann <selena(at)endpoint(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Date: 2009-03-09 00:21:08
Message-ID: 20090309002108.GN3821@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Selena Deckelmann wrote:

> ! parse_error:
> ! if (token == GUC_EOL || token == 0)
> ! ereport(elevel,
> ! (errcode(ERRCODE_SYNTAX_ERROR),
> ! errmsg("syntax error in file \"%s\" line %u, near end of line",
> ! config_file, ConfigFileLineno - 1)));

Not that this has anything to do with the patch at hand, but I remember
thinking about this sort of error message in the past. Would it be
appropriate to move the file name and line number to an errcontext()
field?

I know somebody is going to say "but errcontext is not shown when
verbosity is set to terse", to which I say that we should fix that too.

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Selena Deckelmann <selena(at)endpoint(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Date: 2009-03-09 01:14:26
Message-ID: 6830.1236561266@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
> Not that this has anything to do with the patch at hand, but I remember
> thinking about this sort of error message in the past. Would it be
> appropriate to move the file name and line number to an errcontext()
> field?

I think the message is fine as is. If you moved that information then
you'd have nothing left in the base message but "syntax error", which
is useless.

> I know somebody is going to say "but errcontext is not shown when
> verbosity is set to terse", to which I say that we should fix that too.

No, because the whole point of terse is to be terse. Adding context
to the output would just create a demand for "super terse" mode.

regards, tom lane


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Selena Deckelmann <selena(at)endpoint(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Date: 2009-03-10 09:26:44
Message-ID: 1236677204.31880.388.camel@ebony.2ndQuadrant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Sun, 2009-03-08 at 16:27 -0700, Selena Deckelmann wrote:
> ParseConfigFile currently exits on the first parsing error. Changed
> guc_file.l to report all parsing errors before exiting:
> * Moved parse_error: block inside while() loop
> * Removed cleanup_exit: and associated 'goto'
> * Added ereport if ParseConfigFile() returns false
> * changed OK to ok ;)
> * Added comment - TODO: Report bogus variables in addition to parsing
> errors before bailing out

These are very good changes, good news.

Is it possible to check for parameters that have been changed, yet will
not be applied at reload? It's a common error to change something like
shared_buffers and then expect that to have changed when you reload. It
would be useful to issue messages when that has occurred.

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


From: Selena Deckelmann <selena(at)endpoint(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Date: 2009-03-10 14:30:20
Message-ID: 49B6797C.4020600@endpoint.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi!

Simon Riggs wrote:
> On Sun, 2009-03-08 at 16:27 -0700, Selena Deckelmann wrote:
>> ParseConfigFile currently exits on the first parsing error. Changed
>> guc_file.l to report all parsing errors before exiting:
>> * Moved parse_error: block inside while() loop
>> * Removed cleanup_exit: and associated 'goto'
>> * Added ereport if ParseConfigFile() returns false
>> * changed OK to ok ;)
>> * Added comment - TODO: Report bogus variables in addition to parsing
>> errors before bailing out
>
> These are very good changes, good news.

Thanks :)

> Is it possible to check for parameters that have been changed, yet will
> not be applied at reload?

This was already implemented! :) For example:

LOG: attempted change of parameter "shared_buffers" ignored
DETAIL: This parameter cannot be changed after server start.
LOG: attempted change of parameter "max_prepared_transactions" ignored
DETAIL: This parameter cannot be changed after server start.

A thing that could be added, however, is reporting of all invalid (as
opposed to valid, but requires a restart to apply) parameters before
exiting. This change requires refactoring ProcessConfigFile() more
significantly, as the parsing and validity checks are done separately,
and are exited with gotos. :)

I haven't tried to change this yet, but was planning to.

-selena

--
Selena Deckelmann
End Point Corporation


From: Simon Riggs <simon(at)2ndQuadrant(dot)com>
To: Selena Deckelmann <selena(at)endpoint(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Date: 2009-03-10 15:04:40
Message-ID: 1236697480.28644.27.camel@ebony.2ndQuadrant
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


On Tue, 2009-03-10 at 07:30 -0700, Selena Deckelmann wrote:

> > Is it possible to check for parameters that have been changed, yet will
> > not be applied at reload?
>
> This was already implemented! :) For example:
>
> LOG: attempted change of parameter "shared_buffers" ignored
> DETAIL: This parameter cannot be changed after server start.
> LOG: attempted change of parameter "max_prepared_transactions" ignored
> DETAIL: This parameter cannot be changed after server start.

OK, had that at the back of my mind for a while I guess.

> A thing that could be added, however, is reporting of all invalid (as
> opposed to valid, but requires a restart to apply) parameters before
> exiting. This change requires refactoring ProcessConfigFile() more
> significantly, as the parsing and validity checks are done separately,
> and are exited with gotos. :)
>
> I haven't tried to change this yet, but was planning to.

Can't we just do a reload, but with doit = false?

--
Simon Riggs www.2ndQuadrant.com
PostgreSQL Training, Services and Support


From: Selena Deckelmann <selena(at)endpoint(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Date: 2009-03-10 16:07:47
Message-ID: 49B69053.6040601@endpoint.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Simon Riggs wrote:
> On Tue, 2009-03-10 at 07:30 -0700, Selena Deckelmann wrote:

>> A thing that could be added, however, is reporting of all invalid (as
>> opposed to valid, but requires a restart to apply) parameters before
>> exiting. This change requires refactoring ProcessConfigFile() more
>> significantly, as the parsing and validity checks are done separately,
>> and are exited with gotos. :)
>>
>> I haven't tried to change this yet, but was planning to.
>
> Can't we just do a reload, but with doit = false?

That would also be cool. Like an 'apachectl configtest'.

There are five places where a 'goto' is used in guc-file.l needs to be
changed to make this work (in addition to adding an option to pg_ctl).

It should be pretty straightforward, and I'll have a look at it tonight.

-selena

--
Selena Deckelmann
End Point Corporation


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Selena Deckelmann <selena(at)endpoint(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: postgresql.conf: patch to have ParseConfigFile report all parsing errors, then bail
Date: 2009-03-27 14:07:31
Message-ID: 8118.1238162851@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Selena Deckelmann <selena(at)endpoint(dot)com> writes:
> ParseConfigFile currently exits on the first parsing error. Changed
> guc_file.l to report all parsing errors before exiting:

This seems like basically a good idea, but consider what happens if
you make a really major-league screwup in your postgresql.conf
(say, you accidentally copy the text of "War and Peace" into it).
You'll get megabytes of mostly-useless bleating in your log file.
Multiply that by the number of active backends, if you're unlucky
enough to have done it at log level DEBUG2. And not only are you
bloating your log, but it's going to take a fair amount of time
for all the backends to read and complain (or not) about the whole
file.

So I think a couple of safety valves would be prudent:

1. If IsUnderPostmaster, fall out after the first error, same as now.

2. Even in the postmaster, count the number of errors reported,
and give up after say 100. By that point it's much more likely
that you're reading War and Peace than that you're continuing to
contribute to the enlightenment of the DBA.

regards, tom lane