Re: Forgive trailing semicolons inside of config files

From: Andres Freund <andres(at)anarazel(dot)de>
To: Greg Sabino Mullane <htamfids(at)gmail(dot)com>
Cc: Isaac Morland <isaac(dot)morland(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Forgive trailing semicolons inside of config files
Date: 2023-07-12 02:28:27
Message-ID: 20230712022827.odknzbj73habg2zu@awork3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2023-07-11 12:21:46 -0400, Greg Sabino Mullane wrote:
> On Tue, Jul 11, 2023 at 11:04 AM Isaac Morland <isaac(dot)morland(at)gmail(dot)com>
> > Or maybe there could be a "check configuration" subcommand which checks
> > the configuration.
> >
>
> There are things inside of Postgres once it has started, but yeah,
> something akin to visudo would be nice for editing config files.

You can also do it kind-of-reasonably with the server binary, like:
PGDATA=/srv/dev/pgdev-dev /path/to/postgres -C server_version; echo $?

> > I'd be more interested in improvements in visibility of errors. For
> > example, maybe if I try to start the server and there is a config file
> > problem, I could somehow get a straightforward error message right in the
> > terminal window complaining about the line of the configuration which is
> > wrong.
> >
>
> That ship has long since sailed. We already send a detailed error message
> with the line number, but in today's world of "service start", "systemctl
> start", and higher level of control such as Patroni and Kubernetes, getting
> things to show in a terminal window isn't happening. We can't work around
> 2>&1.

At least with debian's infrastructure, both systemctl start and reload show
errors reasonably well:

start with broken config:
Jul 11 19:13:40 awork3 systemd[1]: Starting postgresql(at)15-test(dot)service - PostgreSQL Cluster 15-test...
Jul 11 19:13:40 awork3 postgresql(at)15-test[3217452]: Error: invalid line 3 in /var/lib/postgresql/15/test/postgresql.auto.conf: dd
Jul 11 19:13:40 awork3 systemd[1]: postgresql(at)15-test(dot)service: Can't open PID file /run/postgresql/15-test.pid (yet?) after start: No such file or directory

reload with broken config:
Jul 11 19:10:38 awork3 systemd[1]: Reloading postgresql(at)15-test(dot)service - PostgreSQL Cluster 15-test...
Jul 11 19:10:38 awork3 postgresql(at)15-test[3217175]: Error: invalid line 3 in /var/lib/postgresql/15/test/postgresql.auto.conf: dd
Jul 11 19:10:38 awork3 systemd[1]: postgresql(at)15-test(dot)service: Control process exited, code=exited, status=1/FAILURE
Jul 11 19:10:38 awork3 systemd[1]: Reload failed for postgresql(at)15-test(dot)service - PostgreSQL Cluster 15-test.

However: It looks like that's all implemented in debian specific tooling,
rather than PG itself. Oops.

Looks like we could make this easier in core postgres by adding one more
sd_notify() call, with something like
STATUS=reload failed due to syntax error in file "/srv/dev/pgdev-dev/postgresql.conf" line 821, near end of line

Greetings,

Andres Freund

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2023-07-12 02:37:09 Re: Forgive trailing semicolons inside of config files
Previous Message Tom Lane 2023-07-12 02:23:34 Re: unrecognized node type while displaying a Path due to dangling pointer