I ran into an issue while trying to setup a simple test system for myself to move from CentOS 6 to 7. When I was about to start a standby slave systemd reported PostgreSQL startup timeout and stopped it. Although it was running perfectly fine doing recovery.
Issue
In var log message systemd reports failure
1 2 3 4 |
systemd: postgresql-9.5.service start operation timed out. Terminating. systemd: Failed to start PostgreSQL 9.5 database server. systemd: Unit postgresql-9.5.service entered failed state. systemd: postgresql-9.5.service failed. |
Meanwhile in postgresql
1 2 3 |
[1342]: [3-1] host=,user=,db=,tx=0,vtx= LOG: received smart shutdown request [1383]: [3-1] host=,user=,db=,tx=0,vtx= LOG: shutting down [1383]: [4-1] host=,user=,db=,tx=0,vtx= LOG: database system is shut down |
Cause
In the systemd script postgresql is being started with -w flag which means ” -w wait until operation complete”. Hence systemd fails after configured timeout.
1 |
ExecStart=/usr/pgsql-9.5/bin/pg_ctl start -D ${PGDATA} -s -w -t 300 |
Fix
Change the -w flag to -W and systemd service file (/usr/lib/systemd/system/postgresql-9.5.service) and reload the daemon.
1 2 |
systemctl daemon-reload service postgresql-9.5 start |
Hopefully this will save you couple of minutes debugging.
Recent comments