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.morland@gmail.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@15-test.service - PostgreSQL Cluster 15-test...
Jul 11 19:13:40 awork3 postgresql@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@15-test.service: Can't open PID file /run/postgresql/15-test.pid (yet?)
afterstart: No such file or directory
reload with broken config:
Jul 11 19:10:38 awork3 systemd[1]: Reloading postgresql@15-test.service - PostgreSQL Cluster 15-test...
Jul 11 19:10:38 awork3 postgresql@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@15-test.service: Control process exited, code=exited, status=1/FAILURE
Jul 11 19:10:38 awork3 systemd[1]: Reload failed for postgresql@15-test.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