Postgres connection not established after abnormal reboot

102 Views Asked by At

After a memory freeze of the unit running postgresql, upon restart the connections cannot be established as

Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5432"?

A rails application can generate a tmp/pid/server.pid file, confirms no connections are established. Now a manual restart with

pg_ctl -D /usr/local/var/[email protected]  -l /usr/local/var/[email protected]/server.log start

pg_ctl: another server might be running; trying to start server anyway
server starting
$ /bin/sh: /usr/local/var/[email protected]/server.log: No such file or directory

then hangs there without returning a prompt. control-c needs to be invoked to get the prompt back. Further:

pg_ctl -D /usr/local/var/[email protected] stop
waiting for server to shut down............................................................... failed
pg_ctl: server does not shut down

directory /usr/local/var/[email protected] contains a postgresql.conf file although it is entirely populated by commented out lines.

I also noted that directory /usr/local/var/log has two files postgres.log and [email protected] which are timestamped to the current minute (which is consistent with the notion of server running). The logs are huge possibly being at the root of the problem in the first place.

What is the best way to reset to reset the log files and get postgresql running properly?

1

There are 1 best solutions below

0
Jerome On BEST ANSWER

Two elements seemed to be at play here.

1 - homebrew which does not support this version of the OS which was broken and had its own process homebrew.mxcl.postgresql.plist for an installation that never could complete.

2 - a second postgresql plist process from manual installation of postgresql /Users/mainuser/Library/LaunchAgents with the properly running db.

The hard reboot launched both leading to a confused situation.

Removal of the unwanted plist and restarting made postgresql available anew.