I'm noticing some errors in my logs when restarting PG 9.6. I also tried upgrading to 10.1, and the problem continues. This is on macOS via a homebrew installation.
First, I shut down with "brew services stop postgres":
2017-12-16 13:56:09.778 EST [34295] LOG: received smart shutdown request
2017-12-16 13:56:09.779 EST [34295] LOG: worker process: logical replication launcher (PID 34316) exited with exit code 1
2017-12-16 13:56:14.787 EST [34317] FATAL: terminating connection due to unexpected postmaster exit
Then I restart it with "brew services start postgres":
2017-12-16 13:56:43.152 EST [5604] LOG: listening on IPv6 address "::1", port 5432
2017-12-16 13:56:43.152 EST [5604] LOG: listening on IPv4 address "127.0.0.1", port 5432
2017-12-16 13:56:43.153 EST [5604] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2017-12-16 13:56:43.215 EST [5619] LOG: database system was interrupted; last known up at 2017-12-16 10:43:27 EST
2017-12-16 13:56:43.407 EST [5619] LOG: database system was not properly shut down; automatic recovery in progress
2017-12-16 13:56:43.409 EST [5619] LOG: redo starts at 0/5B51E580
2017-12-16 13:56:43.409 EST [5619] LOG: invalid record length at 0/5B51E660: wanted 24, got 0
2017-12-16 13:56:43.409 EST [5619] LOG: redo done at 0/5B51E628
2017-12-16 13:56:43.435 EST [5604] LOG: database system is ready to accept connections
This is with a default postgres.conf. I believe the brew services script ends up running:
/usr/local/opt/postgresql/bin/postgres -D /usr/local/var/postgres stop
I also tried using pg_ctl -D /usr/local/var/postgres stop
, but that just gives:
waiting for server to shut down......................................... failed
pg_ctl: server does not shut down
What is the proper way to stop and then re-start postgres?